Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
In Woo checkout, certain actions will trigger a Woo
updated_checkout
orcheckout_error
jQuery event, which will destroy and recreate DOM elements inside the checkout form, causing our reCAPTCHA v2-related event listeners to also be destroyed. When this happens, the checkout form is no longer protected by reCAPTCHA, but since #3644 does a server-side reCAPTCHA verification, it's missing the token required to verify and thus returns an error that makes it impossible to complete checkout.This PR should fix the issue with the following changes:
Recaptcha::can_use_captcha()
method toRecaptcha::verify_recaptcha_on_checkout()
: this ensures that our own RAS auth/registration forms + modal checkout forms all do a server-side reCAPTCHA check, but a standard non-modal checkout does not (we should fix this ASAP, though)document.body
element, instead of inside the form itself: this will ensure that the widget remains in the DOM afterupdated_checkout
orcheckout_error
eventsupdated_checkout
orcheckout_error
event between when the submit button is clicked and the data is posted to the server)How to test the changes in this Pull Request:
updated_checkout
orcheckout_error
jQuery event, which should now also trigger our JS to reattach reCAPTCHA-related event listeners to the form and its children.Other information: