You are here

function theme_uc_cart_block_content in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_cart/uc_cart.module \theme_uc_cart_block_content()
  2. 7.3 uc_cart/uc_cart.theme.inc \theme_uc_cart_block_content()

Theme the shopping cart block content.

1 theme call to theme_uc_cart_block_content()
uc_cart_block in uc_cart/uc_cart.module
Implementation of hook_block().

File

uc_cart/uc_cart.module, line 329

Code

function theme_uc_cart_block_content() {
  global $user;

  // Disabled until we figure out if this is actually screwing up caching. -RS

  //if (!$user->uid && variable_get('cache', 0) !== 0) {

  //  return t('<a href="!url">View</a> your shopping cart.', array('!url' => url('cart')));

  //}
  $output = '';
  $total = 0;
  if (variable_get('uc_cart_show_help_text', FALSE)) {
    $output = '<span class="cart-help-text">' . variable_get('uc_cart_help_text', t('Click title to display cart contents.')) . '</span>';
  }
  $output .= '<div id="block-cart-contents">';
  $items = uc_cart_get_contents();
  $item_count = 0;
  if (!empty($items)) {
    $output .= '<table class="cart-block-table">' . '<tbody class="cart-block-tbody">';
    foreach ($items as $item) {
      $display_item = module_invoke($item->module, 'cart_display', $item);
      if (!empty($display_item)) {
        $output .= '<tr class="cart-block-item"><td class="cart-block-item-qty">' . $display_item['qty']['#default_value'] . 'x</td>' . '<td class="cart-block-item-title">' . $display_item['title']['#value'] . '</td>' . '<td class="cart-block-item-price">' . uc_currency_format($display_item['#total']) . '</td></tr>';
        if ($display_item['options']['#value']) {
          $output .= '<tr><td colspan="3">' . $display_item['options']['#value'] . '</td></tr>';
        }
      }
      $total += $item->price * $item->qty;
      $item_count += $item->qty;
    }
    $output .= '</tbody></table>';
  }
  else {
    $output .= '<p>' . t('There are no products in your shopping cart.') . '</p>';
  }
  $output .= '</div>';
  $item_text = format_plural($item_count, '@count Item', '@count Items');
  $view = '(' . l(t('View cart'), 'cart', array(
    'rel' => 'nofollow',
  )) . ')';
  if (variable_get('uc_checkout_enabled', TRUE)) {
    $checkout = ' (' . l(t('Checkout'), 'cart/checkout', array(
      'rel' => 'nofollow',
    )) . ')';
  }
  $output .= '<table class="cart-block-summary-table"><tbody class="cart-block-summary-tbody">' . '<tr class="cart-block-summary-tr"><td class="cart-block-summary-items">' . $item_text . '</td><td class="cart-block-summary-total">' . '<strong>' . t('Total:') . '</strong> ' . uc_currency_format($total) . '</td></tr>';
  if ($item_count > 0) {
    $output .= '<tr><td colspan="2" class="cart-block-summary-checkout">' . $view . $checkout . '</td></tr>';
  }
  $output .= '</tbody></table>';
  return $output;
}