Change Stripe’s validation fields at the end
-
Hi,
I’m developing a e-commerce using WordPress + Woocommerce. For the payments we are using Stripe and we have configured it successfully. However, we have a question regarding the checkout form. For payments Woocommerce has a form for get personal and shipment information. Stripe’s plugin introduce his own form for credit card’s fields.
We want to add a new field to the form (checkbox to accept privacy policy), and we want to be checked and validated by WordPress system. It works, but for any reason, the form first validate the woocommerce’s fields, then Stripe fields, and finally my new custom field.
I have added this code in functions.php
/* PRIVACY POLICY -> ADD CHECKBOX */ add_action( 'woocommerce_review_order_before_submit', 'add_privacy_checkbox', 9 ); function add_privacy_checkbox() { woocommerce_form_field( 'privacy_policy', array( 'type' => 'checkbox', 'class' => array('form-row privacy'), 'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'), 'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'), 'required' => true, 'label' => 'He leído y aceptado la <a href="www.myweb.com/privacy.php" target="blank">política de privacidad</a>', )); } add_action('woocommerce_checkout_process', 'privacy_checkbox_error_message'); function privacy_checkbox_error_message() { if ( ! (int) isset( $_POST['privacy_policy'] ) ) wc_add_notice( __( 'Debes aceptar nuestra política de privacidad.' ), 'error' ); }
As far I know, we can modify the order of validation using hooks. I think that “woocommerce_checkout_process” should be executed before Stripe is fired, but not…. when I click on CHECKOUT, the system validates all woocommerce fields (including accept terms and conditions), but not my new custom field, before it, the system validates the Stripe’s fields.
Do you know how can we change the order / priority of validation of fields? we want to leave the Stripe’s validation at the end.
Thanks in advance for your time
Cheers
- The topic ‘Change Stripe’s validation fields at the end’ is closed to new replies.