You are here

function commerce_cart_view in Commerce Core 7

Displays the shopping cart form and associated information.

1 string reference to 'commerce_cart_view'
commerce_cart_menu in modules/cart/commerce_cart.module
Implements hook_menu().

File

modules/cart/includes/commerce_cart.pages.inc, line 34
The page and form callbacks for use by the shopping cart.

Code

function commerce_cart_view() {
  global $user;

  // First check to make sure we have a valid order.
  if ($order = commerce_cart_order_load($user->uid)) {
    $wrapper = entity_metadata_wrapper('commerce_order', $order);

    // Only show the cart form if we found product line items.
    if (commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types()) > 0) {

      // Add the form for editing the cart contents.
      $content = commerce_embed_view('commerce_cart_form', 'default', array(
        $order->order_id,
      ), 'cart');
    }
  }
  if (empty($content)) {

    // Default to displaying an empty message.
    $content = theme('commerce_cart_empty_page');
  }
  return $content;
}