You are here

function dc_ajax_add_cart_form_alter in Commerce Ajax Add to Cart 7.2

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

Implements hook_form_alter().

File

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

Code

function dc_ajax_add_cart_form_alter(&$form, &$form_state, $form_id) {
  if (strpos($form_id, 'commerce_cart_add_to_cart_form') !== FALSE) {
    $form['submit']['#ajax'] = array(
      'callback' => 'dc_ajax_add_cart_ajax_cart_form',
      'method' => 'replace',
      'effect' => 'slide',
    );
    if (variable_get(DC_AJAX_ADD_CART_DISPLAY_POPUP, 'display_popup_message') === 'display_popup_message') {
      $form['#attached']['library'][] = array(
        'dc_ajax_add_cart',
        'popup',
      );
    }

    // Rebuild form.
    $form['#submit'][] = 'dc_ajax_add_cart_rebuild_add_to_cart_form';
  }
}