dc_ajax_add_cart_popup.module in Commerce Ajax Add to Cart 8
Display a modal popup after a product is added to the cart with AJAX.
File
modules/dc_ajax_add_cart_popup/dc_ajax_add_cart_popup.moduleView source
<?php
/**
* @file
* Display a modal popup after a product is added to the cart with AJAX.
*/
/**
* Implements hook_theme().
*/
function dc_ajax_add_cart_popup_theme($existing, $type, $theme, $path) {
return [
'dc_ajax_add_cart_popup' => [
'variables' => [
'product_variation' => NULL,
'product_variation_entity' => NULL,
'cart_url' => NULL,
],
],
];
}
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function dc_ajax_add_cart_popup_form_commerce_order_item_dc_ajax_add_cart_form_alter(&$form, &$form_state, $form_id) {
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
$form['actions']['submit']['#ajax']['disable-refocus'] = TRUE;
}
Functions
Name![]() |
Description |
---|---|
dc_ajax_add_cart_popup_form_commerce_order_item_dc_ajax_add_cart_form_alter | Implements hook_form_BASE_FORM_ID_alter(). |
dc_ajax_add_cart_popup_theme | Implements hook_theme(). |