function commerce_shipping_pane_checkout_form_validate in Commerce Shipping 7
Same name and namespace in other branches
- 7.2 includes/commerce_shipping.checkout_pane.inc \commerce_shipping_pane_checkout_form_validate()
shipping pane: validation callback.
File
- includes/
commerce_shipping.checkout_pane.inc, line 108 - Callback functions for the shipping module's checkout panes.
Code
function commerce_shipping_pane_checkout_form_validate($form, &$form_state, $checkout_pane, $order) {
$pane_form = $form[$checkout_pane['pane_id']];
$pane_values =& $form_state['values'][$checkout_pane['pane_id']];
$class = $pane_form['commerce_shipping_plugin']['#value'];
if (!isset($pane_values['shipping_details'])) {
$pane_values['shipping_details'] = array();
}
// Only attempt validation if there were shipping methods available.
if ($pane_values['shipping_methods']) {
// If the selected shipping method was changed, we always need to rebuild
// to update the plugin class.
if ($pane_values['shipping_method'] != $pane_form['shipping_method']['#default_value']) {
return FALSE;
}
// Run the validation that the plugin class inplements.
$result = $class
->submit_form_validate($pane_form['shipping_details'], $pane_values['shipping_details'], array(
$checkout_pane['pane_id'],
'shipping_details',
), $order);
return $result === FALSE ? FALSE : TRUE;
}
// Nothing to validate.
return TRUE;
}