-
Notifications
You must be signed in to change notification settings - Fork 69
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 duplicated enqueued scripts in shortcode checkout #8954
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.25 MB ℹ️ View Unchanged
|
@rafaelzaleski This is not urgent as I'm planning to merge after the code freeze on Sunday so this gets properly tested in all testing rounds from GlobalStep. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good!
✅ This PR fixes the repeated enqueue issue
✅ This PR fixes WooPay OTP modal does not render on the shortcode checkout if BNPL methods are available #8863
✅ Regression tests
Fixes #8863
Changes proposed in this Pull Request
Currently, when multiple WooPayments payment methods are available, certain scripts are being enqueued more than once in the shortcode checkout:
This is because
WC_Payments_Checkout
gets instantiated for every WC payment gateway, and therefore almost the samewp_enqueue_scripts
hook gets called multiple times.This is a long standing issue that was introduced when the UPE payment methods were separated into different WooCommerce payment gateways.
This PR adds a simple check so
wcpay-upe-checkout
andwcpay-fraud-prevention-token
scripts are not enqueued and localized twice.This results in:
wc_tokenization_form_params
variable is not repeated.wcpay_upe_config
variable is not repeated.wcpay_upe_config.icon
,wcpay_upe_config.woopayMinimumSessionData
andwcpay_upe_config.isWooPayEnabled
– The latter causing the issue seen in WooPay OTP modal does not render on the shortcode checkout if BNPL methods are available #8863.WooPay_Session::get_woopay_minimum_session_data
is not called multiple times unnecessarily. 💪Testing instructions
Reproducing the issue
develop
branch.var wcpay_upe_config
.var wcpay_upe_config
.Fixing WooPay OTP modal does not render on the shortcode checkout if BNPL methods are available #8863
Follow the steps to reproduce from #8863 and ensure the issue can no longer be reproduced in this branch.
Regression tests
Perform smoke tests in the following, both in blocks and shortcode checkout:
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.