You are here

function uc_cart_preprocess_block in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 uc_cart/uc_cart.module \uc_cart_preprocess_block()
  2. 7.3 uc_cart/uc_cart.module \uc_cart_preprocess_block()

Preprocesses the cart block output.

File

uc_cart/uc_cart.module, line 539

Code

function uc_cart_preprocess_block(&$variables) {
  global $user;
  if ($variables['block']->module == 'uc_cart' && $variables['block']->delta == 0 && $variables['block']->subject) {
    $cachable = !$user->uid && variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED;
    $collapsible = !$cachable && variable_get('uc_cart_block_collapsible', TRUE);

    // Build the cart image if enabled.
    if (variable_get('uc_cart_block_image', TRUE)) {

      // If the cart is empty or we need a cachable cart block...
      $product_count = count(uc_cart_get_contents());
      if ($cachable || !$product_count) {

        // Use the "empty" cart icon.
        $icon_class = 'cart-block-icon-empty';
      }
      else {

        // Otherwise use the "full" cart icon.
        $icon_class = 'cart-block-icon-full';
      }
    }
    else {
      $icon_class = FALSE;
    }
    $variables['block']->subject = theme('uc_cart_block_title', $variables['block']->subject, $icon_class, $collapsible);
  }
}