• Hi I am trying to add custom phone validation in multistep checkout as shown below

    add_action( ‘woocommerce_after_checkout_validation’, ‘misha_one_err’, 9999, 2);
    function misha_one_err( $fields, $errors ){
    global $woocommerce;

    // Check if set, if its not set add an error. This one is only requite for companies
    if ( ! (preg_match(‘/^[0-9]{10}$/D’, $_POST[‘billing_phone’] ))){
    $errors->add( ‘woocommerce_password_error’, __( ‘Phone is a required field’ ) );
    }
    }

    But the validation error message shows only after clicking the place order button instead of clicking the next button. For required field validation, it works fine. but for custom validation, it shows after pressing the place order.

    Thanks

  • The topic ‘Woocommerce Multistep Custom phone validation’ is closed to new replies.