Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. /**
  2. * Implements hook_commerce_checkout_pane_info_alter
  3. */
  4. function checkout_forms_commerce_checkout_pane_info_alter(&$checkout_panes) {
  5. if(isset($checkout_panes['customer_profile_appointment_d'])){
  6. $checkout_panes['customer_profile_appointment_d']['callbacks']['checkout_form_validate'] = 'checkout_forms_commerce_checkout_form_validate';
  7. }
  8. }
  9.  
  10. /**
  11. * Checkout pane validation override to validate customer profile and appointment
  12. */
  13. function checkout_forms_commerce_checkout_form_validate($form, &$form_state, $checkout_pane, $order) {
  14.  
  15. $first_name = $form_state['values']['customer_profile_appointment_d']['field_first_name_']['und'][0]['value'];
  16. $last_name = $form_state['values']['customer_profile_appointment_d']['field_last_name']['und'][0]['value'];
  17.  
  18. //Some validation tests ... kept it simple for brevity.
  19. if (is_numeric($first_name)) {
  20. form_set_error(customer_profile_appointment_d . '][field_first_name_', t('Numeric characters are not allowed.'));
  21. }
  22.  
  23. //Some validation tests ... kept it simple for brevity.
  24. if (is_numeric($last_name)) {
  25. form_set_error('customer_profile_appointment_d][field_last_name', t('Numeric characters are not allowed.'));
  26. }
  27. return TRUE;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement