function uc_cart_view_form in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_cart/uc_cart.module \uc_cart_view_form()
- 7.3 uc_cart/uc_cart.module \uc_cart_view_form()
Displays a page allowing the customer to view the contents of his or her cart.
Handles simple or complex objects. Some cart items may have a list of products that they represent. These are displayed but are not able to be changed by the customer.
See also
uc_cart_view_form_continue_shopping()
2 string references to 'uc_cart_view_form'
- hook_cart_pane in docs/
hooks.php - Registers callbacks for a cart pane.
- uc_cart_cart_pane in uc_cart/
uc_cart.module - Implements hook_cart_pane().
File
- uc_cart/
uc_cart.module, line 898
Code
function uc_cart_view_form($form_state, $items = NULL) {
$form['items'] = array(
'#type' => 'tapir_table',
'#tree' => TRUE,
);
$context = array(
'revision' => 'themed-original',
'type' => 'amount',
);
$i = 0;
foreach ($items as $item) {
$display_item = module_invoke($item->module, 'cart_display', $item);
if (!empty($display_item)) {
$form['items'][$i] = $display_item;
$form['items'][$i]['image']['#value'] = uc_product_get_picture($display_item['nid']['#value'], 'cart');
$description = $display_item['title']['#value'] . $display_item['description']['#value'];
$form['items'][$i]['desc']['#value'] = $description;
$form['items'][$i]['cart_item_id'] = array(
'#type' => 'hidden',
'#value' => $item->cart_item_id,
);
if (isset($form['items'][$i]['remove'])) {
// Backward compatibility with old checkbox method.
if ($form['items'][$i]['remove']['#type'] == 'checkbox') {
$form['items'][$i]['remove'] = array(
'#type' => 'submit',
'#value' => t('Remove'),
);
}
$form['items'][$i]['remove']['#name'] = 'remove-' . $i;
}
$form['items'][$i]['title']['#type'] = 'value';
$form['items'][$i]['description']['#type'] = 'value';
if (empty($display_item['qty'])) {
$form['items'][$i]['qty'] = array(
'#value' => '',
);
}
$form['items'][$i]['total'] = array(
'#value' => uc_price($display_item['#total'], $context),
'#theme' => 'uc_cart_view_price',
);
$i++;
}
}
$form['items'] = tapir_get_table('uc_cart_view_table', $form['items']);
// If the continue shopping element is enabled...
if (($cs_type = variable_get('uc_continue_shopping_type', 'link')) !== 'none') {
// Setup the text used for the element.
$cs_text = variable_get('uc_continue_shopping_text', '') ? variable_get('uc_continue_shopping_text', '') : t('Continue shopping');
// Add the element to the form based on the element type.
if (variable_get('uc_continue_shopping_type', 'link') == 'link') {
$form['continue_shopping'] = array(
'#value' => l($cs_text, uc_cart_continue_shopping_url()),
);
}
elseif (variable_get('uc_continue_shopping_type', 'link') == 'button') {
$form['continue_shopping'] = array(
'#type' => 'submit',
'#value' => $cs_text,
'#submit' => array(
'uc_cart_view_form_submit',
'uc_cart_view_form_continue_shopping',
),
);
}
}
// Add the control buttons for updating and proceeding to checkout.
$form['update'] = array(
'#type' => 'submit',
'#name' => 'update-cart',
'#value' => t('Update cart'),
'#submit' => array(
'uc_cart_view_form_submit',
'uc_cart_view_form_update_message',
),
);
if (variable_get('uc_checkout_enabled', TRUE)) {
$form['checkout'] = array(
'#type' => 'submit',
'#value' => t('Checkout'),
'#submit' => array(
'uc_cart_view_form_submit',
'uc_cart_view_form_checkout',
),
);
}
return $form;
}