Skip navigation
Help

theme_uc_cart_block_items

6 uc_cart.module theme_uc_cart_block_items($items)
7 uc_cart.theme.inc theme_uc_cart_block_items($variables)

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

Parameters

$variables: An associative array containing:

  • items: An associative array of cart item information containing:

    • qty: Quantity in cart.
    • title: Item title.
    • price: Item price.
    • desc: Item description.
  • collapsed: TRUE or FALSE indicating whether or not the cart block is collapsed.

Related topics

1 theme call to theme_uc_cart_block_items()

File

ubercart/uc_cart/uc_cart.theme.inc, line 136
Theme functions for the uc_cart module.

Code

function theme_uc_cart_block_items($variables) {
  $items = $variables['items'];
  $class = $variables['collapsed'] ? 'cart-block-items collapsed' : 'cart-block-items';

  // If there are items in the shopping cart...
  if ($items) {
    $output = '<table class="' . $class . '"><tbody>';

    // Loop through each item.
    $row_class = 'odd';
    foreach ($items as $item) {
      // 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">' . theme('uc_price', array('price' => $item['price'])) . '</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="' . $class . ' uc-cart-empty">' . t('There are no products in your shopping cart.') . '</p>';
  }

  return $output;
}