You are here

function theme_uc_cart_block_items in Ubercart 6.2

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

Themes the table listing the items in the shopping cart block.

Parameters

$items: An associative array of item information containing the keys 'qty', 'title', 'price', and 'desc'.

1 theme call to theme_uc_cart_block_items()
theme_uc_cart_block_content in uc_cart/uc_cart.module
Themes the shopping cart block content.

File

uc_cart/uc_cart.module, line 671

Code

function theme_uc_cart_block_items($items) {

  // If there are items in the shopping cart...
  if ($items) {
    $output = '<table class="cart-block-items"><tbody>';
    $row_class = 'odd';
    $context = array(
      'revision' => 'themed',
      'type' => 'price',
    );

    // Loop through each item.
    foreach ($items as $item) {
      $context['subject'] = array(
        'cart_item' => $item,
        'node' => node_load($item['nid']),
      );

      // Add the basic row with quantity, title, and price.
      $output .= '<tr class="' . $row_class . '"><td class="cart-block-item-qty">' . $item['qty'] . '</td>' . '<td class="cart-block-item-title">' . $item['title'] . '</td>' . '<td class="cart-block-item-price">' . uc_price($item['price'], $context) . '</td></tr>';

      // Add a row of description if necessary.
      if ($item['desc']) {
        $output .= '<tr class="' . $row_class . '"><td colspan="3" class="cart-block-item-desc">' . $item['desc'] . '</td></tr>';
      }

      // Alternate the class for the rows.
      $row_class = $row_class == 'odd' ? 'even' : 'odd';
    }
    $output .= '</tbody></table>';
  }
  else {

    // Otherwise display an empty message.
    $output = '<p class="uc-cart-empty">' . t('There are no products in your shopping cart.') . '</p>';
  }
  return $output;
}