You are here

function commerce_shipping_example_service_details_form_validate in Commerce Shipping 7.2

Shipping service callback: validates the example shipping service details.

1 string reference to 'commerce_shipping_example_service_details_form_validate'
commerce_shipping_example_commerce_shipping_service_info in modules/commerce_shipping_example.module
Implements hook_commerce_shipping_service_info().

File

modules/commerce_shipping_example.module, line 92
Defines an example shipping method for testing and development.

Code

function commerce_shipping_example_service_details_form_validate($details_form, $details_values, $shipping_service, $order, $form_parents) {
  if (strlen($details_values['name']) < 2) {
    form_set_error(implode('][', array_merge($form_parents, array(
      'name',
    ))), t('You must enter a name two or more characters long.'));

    // Even though the form error is enough to stop the submission of the form,
    // it's not enough to stop it from a Commerce standpoint because of the
    // combined validation / submission going on per-pane in the checkout form.
    return FALSE;
  }
}