You are here

function commerce_shipping_recalculate_services_validate in Commerce Shipping 7.2

Validate callback for recalculating shipping services.

1 string reference to 'commerce_shipping_recalculate_services_validate'
commerce_shipping_form_commerce_checkout_form_alter in ./commerce_shipping.module
Implements hook_form_FORM_ID_alter().

File

includes/commerce_shipping.checkout_pane.inc, line 182
Callback functions for the shipping module's checkout panes.

Code

function commerce_shipping_recalculate_services_validate($form, &$form_state) {

  // Call all validation callbacks.
  $recalculate = commerce_shipping_recalculate_services($form, $form_state);

  // Retrieve the form validation errors.
  $errors = drupal_get_messages('error');

  // If there were any errors, we clear them.
  if (!empty($errors)) {
    form_clear_error();
    $recalculate = FALSE;
  }

  // If we previously validated, and now validation fails, then we need to
  // rebuild the form.
  if (!empty($form_state['recalculate']) && !$recalculate) {
    $form_state['rebuild'] = TRUE;
  }

  // Store the validation result so that it can be examined
  // in the submit handler.
  $form_state['recalculate'] = $recalculate;
  return TRUE;
}