duanhanglekr37902 2018-10-03 11:27
浏览 107

使用Stripe重新订购Woocommerce结帐验证

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&iacute;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&iacute;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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么