function uc_product_add_to_cart_form in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_product/uc_product.module \uc_product_add_to_cart_form()
- 7.3 uc_product/uc_product.module \uc_product_add_to_cart_form()
Form to add the $node product to the cart.
Parameters
$node: A product node.
See also
uc_product_add_to_cart_form_submit()
2 string references to 'uc_product_add_to_cart_form'
- theme_uc_product_add_to_cart in uc_product/
uc_product.module - Wraps the "Add to Cart" form in a <div>.
- uc_product_forms in uc_product/
uc_product.module - Implements hook_forms().
File
- uc_product/
uc_product.module, line 1472 - The product module for Ubercart.
Code
function uc_product_add_to_cart_form($form_state, $node) {
$form = array();
$form['#validate'][] = 'uc_product_add_to_cart_form_validate';
$form['#submit'][] = 'uc_product_add_to_cart_form_submit';
$form['nid'] = array(
'#type' => 'value',
'#value' => $node->nid,
);
if ($node->default_qty > 0 && variable_get('uc_product_add_to_cart_qty', FALSE)) {
$form['qty'] = array(
'#type' => 'uc_quantity',
'#title' => t('Quantity'),
'#default_value' => $node->default_qty,
);
}
else {
$form['qty'] = array(
'#type' => 'hidden',
'#value' => $node->default_qty ? $node->default_qty : 1,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => variable_get('uc_product_add_to_cart_text', t('Add to cart')),
'#id' => 'edit-submit-' . $node->nid,
'#attributes' => array(
'class' => 'node-add-to-cart',
),
);
$form['node'] = array(
'#type' => 'value',
'#value' => $node,
);
uc_form_alter($form, $form_state, __FUNCTION__);
return $form;
}