function uc_order_add_product_form in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_order/uc_order.module \uc_order_add_product_form()
- 6.2 uc_order/uc_order.admin.inc \uc_order_add_product_form()
Sets the quantity and attributes of a product added to the order.
See also
1 call to uc_order_add_product_form()
- uc_order_pane_products in uc_order/
uc_order.order_pane.inc - Handles the "Products" order pane.
2 string references to 'uc_order_add_product_form'
- uc_attribute_uc_form_alter in uc_attribute/
uc_attribute.module - Implements hook_uc_form_alter().
- uc_product_kit_uc_form_alter in uc_product_kit/
uc_product_kit.module - Implements hook_uc_form_alter().
File
- uc_order/
uc_order.order_pane.inc, line 329 - This file contains the callbacks for the default order panes supplied with Ubercart and their corresponding helper functions.
Code
function uc_order_add_product_form($form, &$form_state, $order, $node) {
$data = array();
if (isset($form_state['values']['product_controls']['qty'])) {
$data += module_invoke_all('uc_add_to_cart_data', $form_state['values']['product_controls']);
}
if (!empty($node->data) && is_array($node->data)) {
$data += $node->data;
}
$node = uc_product_load_variant(intval($form_state['values']['product_controls']['nid']), $data);
$form['title'] = array(
'#markup' => '<h3>' . check_plain($node->title) . '</h3>',
);
$form['nid'] = array(
'#type' => 'hidden',
'#value' => $node->nid,
);
$form['qty'] = array(
'#type' => 'uc_quantity',
'#title' => theme('uc_qty_label'),
'#default_value' => 1,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Add to order'),
'#submit' => array(
'uc_order_edit_products_add',
),
'#ajax' => array(
'callback' => 'uc_order_pane_products_ajax_callback',
'wrapper' => 'product-controls',
),
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array(
'uc_order_pane_products_select',
),
'#ajax' => array(
'callback' => 'uc_order_pane_products_ajax_callback',
'wrapper' => 'product-controls',
),
'#limit_validation_errors' => array(),
);
$form['node'] = array(
'#type' => 'value',
'#value' => $node,
);
uc_form_alter($form, $form_state, __FUNCTION__);
return $form;
}