Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove reCAPTCHA for Woo from modal checkout #1984

Merged
merged 11 commits into from
Dec 4, 2024
60 changes: 33 additions & 27 deletions includes/class-modal-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,34 +791,40 @@ public static function remove_hooks() {
if ( ! self::is_modal_checkout() ) {
return;
}
$remove_list = [
// reCAPTCHA for WooCommerce.
[
'hook' => 'woocommerce_review_order_before_payment',
'callback' => 'rcfwc_field_checkout',
],
[
'hook' => 'woocommerce_review_order_after_payment',
'callback' => 'rcfwc_field_checkout',
],
[
'hook' => 'woocommerce_before_checkout_billing_form',
'callback' => 'rcfwc_field_checkout',
],
[
'hook' => 'woocommerce_after_checkout_billing_form',
'callback' => 'rcfwc_field_checkout',
],
[
'hook' => 'woocommerce_review_order_before_submit',
'callback' => 'rcfwc_field_checkout',
],
[
'hook' => 'woocommerce_checkout_process',
'callback' => 'rcfwc_checkout_check',
],
];

$remove_list = [];

// reCaptcha for WooCommerce.
if ( method_exists( 'I13_Woo_Recpatcha', '__construct' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking nit: we can just do a check for the class with class_exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Raz! Fixed in ad577d6.

global $i13_woo_recpatcha;
array_push(
$remove_list,
[
'hook' => 'woocommerce_review_order_before_payment',
'callback' => array( $i13_woo_recpatcha, 'i13woo_extra_checkout_fields' ),
],
[
'hook' => 'woocommerce_after_checkout_validation',
'callback' => array( $i13_woo_recpatcha, 'i13_woocomm_validate_checkout_captcha' ),
],
[
'hook' => 'woocommerce_pay_order_before_submit',
'callback' => array( $i13_woo_recpatcha, 'i13woo_extra_checkout_fields' ),
],
[
'hook' => 'woocommerce_review_order_before_submit',
'callback' => array( $i13_woo_recpatcha, 'i13woo_extra_checkout_fields' ),
],
[
'hook' => 'woocommerce_pay_order_before_submit',
'callback' => array( $i13_woo_recpatcha, 'i13woo_extra_checkout_fields_pay_order' ),
],
[
'hook' => 'woocommerce_proceed_to_checkout',
'callback' => array( $i13_woo_recpatcha, 'i13_woocommerce_payment_request_btn_captcha' ),
]
);
}
/**
* Filters the hooks to remove from the modal checkout.
*
Expand Down