0

I'm developing a Gateway Payment module for Ubercart. It is necessary to validate that the User does not digit three ceros -000- (bank policy) before the order review form. I've seen that Ubercart does the CCV's validation in the uc_credit.module

      if (variable_get('uc_credit_cvv_enabled', TRUE) && !_valid_cvv($cc_data['cc_cvv'])) {
        if (!$silent) {
          drupal_set_message(t('You have entered an invalid CVV number.'), 'error');
        }
      $return = FALSE;
      }

How could I add my validation without hacking Ubercart modules.

Thanks in advance.

1 Answer 1

0

You can create a custom validation function in your module and name it whatever you like for example 'custom_validation_function'. and in the same module add this validation function to the form's validation list by using form_alter.

function <module_name>_form_alter(&$form, &$form_state, $form_id) {

  if ($form_id == '<ubercart_form_id>') {
    $form['#validate'][] = 'custom_validation_function';
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.