You are here

function uc_cart_checkout_form_validate in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart.module \uc_cart_checkout_form_validate()
  2. 6.2 uc_cart/uc_cart.pages.inc \uc_cart_checkout_form_validate()

Form validation for uc_cart_checkout_form().

See also

uc_cart_checkout_form()

uc_cart_checkout_form_submit()

File

uc_cart/uc_cart.pages.inc, line 335
Cart menu items.

Code

function uc_cart_checkout_form_validate($form, &$form_state) {
  $order = $form_state['storage']['order'];

  // Update the order "modified" time to prevent timeout on ajax requests.
  $order->modified = REQUEST_TIME;

  // Validate/process the cart panes.  A FALSE value results in failed checkout.
  $form_state['checkout_valid'] = TRUE;
  foreach (element_children($form_state['values']['panes']) as $pane_id) {
    $func = _uc_checkout_pane_data($pane_id, 'callback');
    if (is_string($func) && function_exists($func)) {
      $isvalid = $func('process', $order, $form, $form_state);
      if ($isvalid === FALSE) {
        $form_state['expanded_panes'][] = $pane_id;
        $form_state['checkout_valid'] = FALSE;
      }
    }
  }

  // Reload line items and save order.
  $order->line_items = uc_order_load_line_items($order);
  uc_order_save($order);
}