You are here

function template_preprocess_dc_ajax_shopping_cart_teaser in Commerce Ajax Add to Cart 7

Same name and namespace in other branches
  1. 7.2 dc_ajax_add_cart.module \template_preprocess_dc_ajax_shopping_cart_teaser()

Add more variables to shopping cart teaser.

Default template: ajax-shopping-cart-teaser.tpl.php.

Parameters

array $variables: An associative array containing:

  • order: Order object for the current user.
  • quantity: Number of items present in the cart.
  • total: Array containing the total amount and default currency code used in the site.

File

./dc_ajax_add_cart.module, line 616
Ajax add to cart module.

Code

function template_preprocess_dc_ajax_shopping_cart_teaser(&$variables) {

  // Default currency array.
  $currency = commerce_currency_load(commerce_default_currency());
  $image_cart_icon_path = drupal_get_path('module', 'dc_ajax_add_cart') . '/images/shopping-cart.png';
  $variables['total_amount'] = commerce_currency_format($variables['total']['amount'], $currency['code']);
  $variables['cart_icon'] = theme('image', array(
    'path' => $image_cart_icon_path,
  ));

  // Create new theme variables related to configuration.
  $variables['configuration']['empty_cart_teaser_message'] = check_plain(variable_get(DC_AJAX_ADD_CART_EMPTY_CART_TEASER_MESSAGE, t('Empty')));
  $cart_link_text = format_plural($variables['quantity'], '1 ' . check_plain(variable_get(DC_AJAX_ADD_CART_ITEM_SUFFIX_TEXT, t('item'))), '@count ' . check_plain(variable_get(DC_AJAX_ADD_CART_ITEM_SUFFIX_TEXT, t('items'))));
  $variables['cart_link'] = l($cart_link_text, 'cart', array(
    'attributes' => array(
      'class' => array(
        'quantity',
      ),
    ),
  ));
}