簡體   English   中英

Woocommerce結帳不使用沒有CAPTCHA reCAPTCHA的WooCommerce插件

[英]Woocommerce Checkout not Working with No CAPTCHA reCAPTCHA for WooCommerce Plugin

當我激活'沒有CAPTCHA reCAPTCHA for WooCommerce'插件時,在客戶選中“創建帳戶?”時,在WooCommerce的結帳頁面上 復選框和放置順序,它不起作用。 頁面只是滾動到頂部,沒有任何動作。

任何想法?

Reagrds Faizan

該插件只是為了保護Woocommerce注冊和登錄,而不是結帳流程。

為了保護Checkout Process,我像這樣調整了registration.php

class WC_Ncr_Registration_Captcha extends WC_Ncr_No_Captcha_Recaptcha {

/** Initialize actions and filters */
public static function initialize() {

    // initialize if login is activated
    if ( isset( self::$plugin_options['captcha_wc_registration'] ) || self::$plugin_options['captcha_wc_registration'] == 'yes' ) {
        // adds the captcha to the registration form
        add_action( 'register_form', array( __CLASS__, 'display_captcha' ) );



    }


        //added the following lines to the plugin

        add_action('woocommerce_after_checkout_billing_form', array( __CLASS__, 'display_captcha' ));

        add_action('woocommerce_checkout_process', array(
            __CLASS__,
            'validate_captcha_wc_checkout'
        ), 10, 3 );
 //added the previous lines to the plugin

}


/**
 * Verify the captcha answer
 *
 * @param $validation_errors
 * @param $username
 * @param $email
 *
 * @return WP_Error
 */
public static function validate_captcha_wc_registration( $validation_errors, $username, $email ) {
    if ( ! isset( $_POST['g-recaptcha-response'] ) || ! self::captcha_wc_verification() ) {
        $validation_errors = new WP_Error( 'failed_verification', self::$error_message );
    }

    return $validation_errors;
}


    //added the following lines to the plugin

    public static function validate_captcha_wc_checkout( $validation_errors, $username, $email ) {
    if ( ! isset( $_POST['g-recaptcha-response'] ) || ! self::captcha_wc_verification() ) {
        wc_add_notice(__( 'Please verify you are not a robot.' ), 'error' );
    }
}
  //added the previous lines to the plugin


}

添加到functions.php

function my_woocommerce_before_checkout_process() {
    remove_filter( 'woocommerce_registration_errors', array('WC_Ncr_Registration_Captcha', 'validate_captcha_wc_registration'), 10 );
}
add_action('woocommerce_before_checkout_process', 'my_woocommerce_before_checkout_process');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM