当我激活“No CAPTCHA reCAPTCHA for WooCommerce”插件时,因此在 WooCommerce 的结帐页面上,当客户检查“创建帐户?”时复选框和下订单相比,它不起作用。页面只是滚动到顶部,没有任何操作。
任何想法?
问候
费赞
该插件的编写目的只是为了保护 Woocommerce 注册和登录,而不是结账流程。
为了保护结账流程,我像这样调整了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
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)