You are here

function theme_uc_cart_review_table in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 uc_cart/uc_cart.theme.inc \theme_uc_cart_review_table()

Formats the cart contents table on the checkout page.

Parameters

$variables: An associative array containing:

  • show_subtotal: TRUE or FALSE indicating if you want a subtotal row displayed in the table.
  • items: An associative array of cart item information containing:
    • qty: Quantity in cart.
    • title: Item title.
    • price: Item price.
    • desc: Item description.

Return value

The HTML output for the cart review table.

2 theme calls to theme_uc_cart_review_table()
uc_checkout_pane_cart in uc_cart/uc_cart_checkout_pane.inc
Displays the cart contents for review during checkout.
uc_paypal_ec_submit in payment/uc_paypal/uc_paypal.pages.inc
Presents the final total to the user for checkout!

File

uc_cart/uc_cart_checkout_pane.inc, line 478
Callbacks for the default Ubercart checkout panes plus helper functions.

Code

function theme_uc_cart_review_table($variables) {
  $items = $variables['items'];
  $show_subtotal = $variables['show_subtotal'];
  $subtotal = 0;

  // Set up table header.
  $header = array(
    array(
      'data' => theme('uc_qty_label'),
      'class' => array(
        'qty',
      ),
    ),
    array(
      'data' => t('Products'),
      'class' => array(
        'products',
      ),
    ),
    array(
      'data' => t('Price'),
      'class' => array(
        'price',
      ),
    ),
  );

  // Set up table rows.
  $display_items = uc_order_product_view_multiple($items);
  if (!empty($display_items['uc_order_product'])) {
    foreach (element_children($display_items['uc_order_product']) as $key) {
      $display_item = $display_items['uc_order_product'][$key];
      $subtotal += $display_item['total']['#price'];
      $rows[] = array(
        array(
          'data' => $display_item['qty'],
          'class' => array(
            'qty',
          ),
        ),
        array(
          'data' => $display_item['product'],
          'class' => array(
            'products',
          ),
        ),
        array(
          'data' => $display_item['total'],
          'class' => array(
            'price',
          ),
        ),
      );
    }
  }

  // Add the subtotal as the final row.
  if ($show_subtotal) {
    $rows[] = array(
      'data' => array(
        // One cell
        array(
          'data' => array(
            '#theme' => 'uc_price',
            '#prefix' => '<span id="subtotal-title">' . t('Subtotal:') . '</span> ',
            '#price' => $subtotal,
          ),
          // Cell attributes
          'colspan' => 3,
          'class' => array(
            'subtotal',
          ),
        ),
      ),
      // Row attributes
      'class' => array(
        'subtotal',
      ),
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'class' => array(
        'cart-review',
      ),
    ),
  ));
}