function template_preprocess_dc_ajax_add_to_cart_message in Commerce Ajax Add to Cart 7
Same name and namespace in other branches
- 7.2 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 644 - Ajax add to cart module.
Code
function template_preprocess_dc_ajax_add_to_cart_message(&$variables) {
// Default currency array.
$currency = commerce_currency_load(commerce_default_currency());
$product_price = commerce_product_calculate_sell_price($variables['product']);
$variables['product_per_unit_price'] = commerce_currency_format($product_price['amount'], $currency['code']);
$variables['product_price_total'] = commerce_currency_format($variables['quantity'] * $product_price['amount'], $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');
}