You are here

function uc_ajax_cart_block_view in Ubercart AJAX Cart 7.2

Implements hook_block_view().

File

./uc_ajax_cart.module, line 345

Code

function uc_ajax_cart_block_view($delta) {
  if (TRUE) {

    //Only a wrapper to uc_cart_block
    $cartContent = uc_cart_get_contents();
    $hasItems = FALSE;
    if (count($cartContent) > 0) {
      $hasItems = TRUE;
    }
    $content['subject'] = theme('uc_ajax_cart_block_header', array(
      'text' => $hasItems,
    ));
    global $user;
    $cacheEnabled = variable_get('cache', 0);
    if (!$user->uid && $cacheEnabled > 0) {
      $loadOnPageView = variable_get('uc_ajax_cart_cart_cached_load', 0);
      if ($loadOnPageView != 0) {
        $content['content'] = '<div id="ajaxCartUpdate" class="load-on-view"><p>' . t('Loading cart') . '</p></div>';
      }
      else {

        // TODO Please change this theme call to use an associative array for the $variables parameter.
        $content['content'] = '<div id="ajaxCartUpdate">' . theme('uc_ajax_cart_block_content_cached') . '</div>';
      }
    }
    else {
      $load_on_page_view_class = variable_get('uc_ajax_cart_cart_cached_load', 0) ? ' class="load-on-view"' : '';
      if ($hasItems == TRUE) {
        $content['content'] = '<div id="ajaxCartUpdate" ' . $load_on_page_view_class . '>' . theme('uc_ajax_cart_block_content', array(
          'items' => $cartContent,
        )) . '</div>';
      }
      else {

        // TODO Please change this theme call to use an associative array for the $variables parameter.
        $content['content'] = '<div id="ajaxCartUpdate" ' . $load_on_page_view_class . '>' . theme('uc_ajax_cart_block_content_empty') . '</div>';
      }
    }
    return $content;
  }
}