You are here

function theme_cart_review_table in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_cart/uc_cart_checkout_pane.inc \theme_cart_review_table()
2 theme calls to theme_cart_review_table()
uc_checkout_pane_cart in uc_cart/uc_cart_checkout_pane.inc
Display the cart contents for review during checkout.
uc_paypal_ec_submit in payment/uc_paypal/uc_paypal.module

File

uc_cart/uc_cart_checkout_pane.inc, line 540
This file contains the callbacks for the default checkout panes supplied with Ubercart and their corresponding helper functions.

Code

function theme_cart_review_table($show_subtotal = TRUE) {
  $items = uc_cart_get_contents();
  $subtotal = 0;
  $output = '<table class="cart-review"><thead>' . '<tr class="first last odd"><td class="first odd qty">' . t('Qty') . '</td><td class="even products">' . t('Products') . '</td><td class="last odd price">' . t('Price') . '</td></tr></thead><tbody>';
  $row = 1;
  for ($i = 0; $i < count($items); $i++) {
    $item = $items[$i];
    $rows = array();
    foreach ($item->options as $option) {

      // $rows[] = $option['attribute'] .': '. $option['name'];
      $rows[] = t('@attribute: @option', array(
        '@attribute' => $option['attribute'],
        '@option' => $option['name'],
      ));
    }
    $desc = check_plain($item->title) . theme('item_list', $rows, NULL, 'ul', array(
      'class' => 'product-options',
    ));
    $total = $item->qty ? $item->qty * $item->price : $item->price;
    $subtotal += $total;
    $qty = $item->qty ? $item->qty : '';
    $tr_class = $i % 2 == 0 ? 'even' : 'odd';
    if ($show_subtotal && $i == count($items)) {
      $tr_class .= ' last';
    }
    $output .= '<tr class="' . $tr_class . '"><td class="qty">' . t('!qtyx', array(
      '!qty' => $qty,
    )) . '</td><td class="products">' . $desc . '</td><td class="price">' . uc_currency_format($total) . '</td></tr>';
  }
  if ($show_subtotal) {
    $tr_class = $tr_class == 'even' ? 'odd' : 'even';
    $output .= '<tr class="' . $tr_class . ' last"><td class="subtotal" ' . 'colspan="4"><span id="subtotal-title">' . t('Subtotal:') . '</span> ' . uc_currency_format($subtotal) . '</td></tr>';
  }
  $output .= '</tbody></table>';
  return $output;
}