You are here

function uc_coupon_checkout_update in Ubercart Discount Coupons 7.2

Same name and namespace in other branches
  1. 7.3 uc_coupon.module \uc_coupon_checkout_update()

Ajax callback for checkout form.

1 string reference to 'uc_coupon_checkout_update'
uc_checkout_pane_coupon in ./uc_coupon.module
Checkout Pane callback function.

File

./uc_coupon.module, line 1392

Code

function uc_coupon_checkout_update($form, $form_state) {
  $commands[] = ajax_command_replace('#coupon-pane', trim(drupal_render($form['panes']['coupon'])));
  if (isset($form['panes']['coupon_automatic'])) {
    $commands[] = ajax_command_replace('#coupon_automatic-pane', trim(drupal_render($form['panes']['coupon_automatic'])));
  }
  if (isset($form['panes']['payment'])) {
    $commands[] = ajax_command_replace('#payment-pane', trim(drupal_render($form['panes']['payment'])));
  }
  if (isset($form['panes']['quotes'])) {
    $commands[] = ajax_command_replace('#quotes-pane', trim(drupal_render($form['panes']['quotes'])));
  }
  if (variable_get('uc_coupon_show_in_cart', TRUE) && isset($form['panes']['cart']['cart_review_table'])) {
    $commands[] = ajax_command_html('#cart-pane>div', drupal_render($form['panes']['cart']['cart_review_table']));
  }

  // Clear the coupon code, but only if the submission was successful.
  if (count(drupal_get_messages('error', FALSE)) == 0) {
    $commands[] = ajax_command_invoke('#coupon-pane input[type=text]', 'val', array(
      '',
    ));
  }

  // Make sure all checkboxes are checked.
  $commands[] = ajax_command_invoke('#coupon-pane input[type=checkbox]', 'attr', array(
    'checked',
    'true',
  ));

  // Show any messages.
  $commands[] = ajax_command_html('#coupon-messages', theme('status_messages'));
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}