You are here

function commerce_coupon_add_coupon_callback in Commerce Coupon 7.2

Same name and namespace in other branches
  1. 7 includes/commerce_coupon.checkout_pane.inc \commerce_coupon_add_coupon_callback()

Ajax callback: coupon add button.

1 string reference to 'commerce_coupon_add_coupon_callback'
commerce_coupon_pane_checkout_form in includes/commerce_coupon.checkout_pane.inc
Checkout pane callback: coupon checkout form.

File

includes/commerce_coupon.checkout_pane.inc, line 142
Commerce Checkout pane implementations.

Code

function commerce_coupon_add_coupon_callback($form, &$form_state) {

  // Re-render the cart summary.
  list($view_id, $display_id) = explode('|', variable_get('commerce_cart_contents_pane_view', 'commerce_cart_summary|default'));
  $cart_summary = commerce_embed_view($view_id, $display_id, array(
    $form_state['order']->order_id,
  ));
  $commands[] = ajax_command_replace('.cart_contents .view:not(.cart_contents .view .view)', $cart_summary);

  // Re-render coupon pane.
  $coupon_pane = $form['commerce_coupon'];
  $commands[] = ajax_command_replace('#commerce-checkout-coupon-ajax-wrapper', drupal_render($coupon_pane));

  // Allow other modules to alter the commands.
  drupal_alter('commerce_coupon_add_coupon_ajax', $commands, $form, $form_state);
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}