You are here

function template_preprocess_dc_ajax_add_to_cart_message in Commerce Ajax Add to Cart 7.2

Same name and namespace in other branches
  1. 7 dc_ajax_add_cart.module \template_preprocess_dc_ajax_add_to_cart_message()

Add more variables to add to cart message popup message.

Default template: add-to-cart-message.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 642
Ajax add to cart module.

Code

function template_preprocess_dc_ajax_add_to_cart_message(&$variables) {
  $currency = dc_ajax_add_cart_currency_load();
  $product_price = $variables['line_item']->commerce_unit_price[LANGUAGE_NONE][0]['amount'];
  $variables['product_per_unit_price'] = commerce_currency_format($product_price, $currency['code']);
  $variables['product_price_total'] = commerce_currency_format($variables['quantity'] * $product_price, $currency['code']);

  // Create new theme variables related to configuration.
  $variables['configuration']['success_message'] = check_plain(variable_get(DC_AJAX_ADD_CART_SUCCESS_MESSAGE, t('Item successfully added to cart')));
  $variables['configuration']['popup_checkout'] = check_plain(variable_get(DC_AJAX_ADD_CART_POPUP_CHECKOUT, t('Go to checkout')));
  $variables['checkout_link'] = l(variable_get(DC_AJAX_ADD_CART_POPUP_CHECKOUT, t('Go to checkout')), 'cart');
  $variables['configuration']['popup_continue_shopping'] = check_plain(variable_get(DC_AJAX_ADD_CART_POPUP_CONTINUE_SHOPPING, t('Continue shopping')));
  $variables['configuration']['popup_product_name_display'] = variable_get(DC_AJAX_ADD_CART_POPUP_PRODUCT_NAME_DISPLAY, 1);
  $variables['configuration']['popup_product_name_label'] = variable_get(DC_AJAX_ADD_CART_POPUP_PRODUCT_NAME_LABEL, 'no_display_label');
  $variables['product_name'] = check_plain($variables['product']->title);
  $variables['configuration']['popup_product_price_display'] = variable_get(DC_AJAX_ADD_CART_POPUP_PRODUCT_PRICE_DISPLAY, 1);
  $variables['configuration']['popup_product_price_label'] = variable_get(DC_AJAX_ADD_CART_POPUP_PRODUCT_PRICE_LABEL, 'display_label');
  $variables['configuration']['popup_product_quantity_display'] = variable_get(DC_AJAX_ADD_CART_POPUP_PRODUCT_QUANTITY_DISPLAY, 1);
  $variables['configuration']['popup_product_quantity_label'] = variable_get(DC_AJAX_ADD_CART_POPUP_PRODUCT_QUANTITY_LABEL, 'display_label');
  $variables['configuration']['popup_product_total_display'] = variable_get(DC_AJAX_ADD_CART_POPUP_PRODUCT_TOTAL_DISPLAY, 1);
  $variables['configuration']['popup_product_total_label'] = variable_get(DC_AJAX_ADD_CART_POPUP_PRODUCT_TOTAL_LABEL, 'display_label');
}