Re: Themeing attributes via uc_product_add_to_cart

mk31762's picture
Offline
Joined: 05/28/2009
Juice: 44
Re: Themeing attributes via uc_product_add_to_cart

Well, first of all, I didn't realize there was a uc_attribute_add_to_cart theme. Still, I need to theme the entire add to cart form. I also didn't realize that the #theme attribute had to refer to a function defined in hook_theme().

So, in case anyone else does a similar search and comes across this post, here's what I did.

First, hook_theme():

<?php
function my_module_theme() {
    return array(
       
'add_to_cart_form' => array(
           
'arguments' => array($form => NULL),
        ),
    );
}
?>

Then, hook_form_alter(), with a check to make sure the containing node type was of the type containing the attributes I need to style.

<?php
function my_module_form_alter(&$form, $form_state, $form_id) {
...
    if(
$form['#parameters'][2]->type == 'my_type') {
       
$form['#theme']  = 'add_to_cart_form';
    }
}
?>

And, finally, my theme function, complete with form elements and product attributes.

<?php
function theme_add_to_cart_form($form) {
...
}
?>
Themeing attributes via uc_product_add_to_cart By: mk31762 (11 replies) Wed, 07/01/2009 - 17:09