You are here

function uc_cart_view in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart.module \uc_cart_view()
  2. 7.3 uc_cart/uc_cart.pages.inc \uc_cart_view()

Displays the cart view page.

Show the products in the cart with a form to adjust cart contents or go to checkout.

1 string reference to 'uc_cart_view'
uc_cart_menu in uc_cart/uc_cart.module
Implements hook_menu().

File

uc_cart/uc_cart.pages.inc, line 14
Cart menu items.

Code

function uc_cart_view() {

  // Failsafe so that this function only works when called with no arguments.
  // This prevents the accidental wiping of the cart_order session variable.
  if (func_num_args() > 0) {
    return drupal_not_found();
  }

  // Clear the cart order session variable if it exists.
  if (!empty($_SESSION['cart_order'])) {
    unset($_SESSION['cart_order']);
  }

  // Load the array of shopping cart items.
  $items = uc_cart_get_contents();

  // Display the empty cart page if there are no items in the cart.
  if (empty($items)) {
    return theme('uc_empty_cart');
  }

  // Load through the cart panes...
  $output = '';
  foreach (uc_cart_cart_pane_list($items) as $pane) {

    // If the pane is enabled...
    if ($pane['enabled']) {

      // Add its output to the cart view.
      $output .= $pane['body'];
    }
  }

  // Add a custom cart breadcrumb if specified.
  if (($text = variable_get('uc_cart_breadcrumb_text', '')) !== '') {
    $link = l($text, variable_get('uc_cart_breadcrumb_url', '<front>'));
    drupal_set_breadcrumb(array(
      $link,
    ));
  }
  return $output;
}