-
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
Migrate to custom containers and better elements scoping #9782
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: +103 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
client/checkout/utils/upe.js
Outdated
? 'wc-woocommerce_payments-payment-token-new' | ||
: `wc-woocommerce_payments_${ paymentMethodType }-payment-token-new`; |
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.
This is a small refactor that I believe makes the code more readable by removing the prefix and suffix concepts
@@ -83,9 +58,11 @@ export const getHiddenBillingFields = ( enabledBillingFields ) => { | |||
}; | |||
}; | |||
|
|||
export const getUpeSettings = () => { | |||
export const getUpeSettings = ( paymentMethodType ) => { |
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.
I decided to add paymentMethodType
here because the current idea behind getUpeSettings
is that we run it for every gateway/payment method and it should theoretically check for every payment method type. So we let shouldIncludeTerms
to scope by the wcpay-upe-form
which has the payment method type equal to the one coming as a parameter here, and check from there
client/checkout/utils/upe.js
Outdated
const upeContainer = document.querySelector( | ||
'.payment_method_woocommerce_payments_' + paymentMethodType | ||
); | ||
const upeContainer = upeElement.closest( 'li.wc_payment_method' ); |
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.
Traversing up trying to find the first parent which will be ready to be used so that we can properly hide/show the gateway
if ( ! empty( $this->gateway->get_description() ) ) : ?> | ||
<p><?php echo wp_kses_post( $this->gateway->get_description() ); ?></p> | ||
?> | ||
<div class="wcpay-upe-form" |
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.
This is the main wrapper, which should serve as the base for all DOM traversal moving forward. Ideally, we should aim to locate this container in the DOM and then traverse within it to find the relevant elements needed for our purposes
14c21f6
to
6a2bc69
Compare
3defc99
to
7e7de87
Compare
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.
This looks good on my end, I don't see any blocking issues. Thank you for all the changes!
After the reviews so far, I thought I would attach the most recent testing round results I performed with the Vendrify theme. Screen.Recording.2024-12-04.at.10.26.47.mov |
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.
Everything is testing well with the changes and checkouts are processing as expected. Checkout is working on Vendrify, but a couple things (which I'm not sure if are meant to be fixed in this PR) stand out.
Vendrify theme only
- Dynamic payment method filtering isn't working during checkout. Only the payment methods supported by the country set at page load are displayed and changing the billing country has no effect on the payment methods.
- Pay for Order - I think is beyond our control but surfacing anyways.
a. If WooPayments is active, it's always displayed as the top payment method, regardless of payment method ordering at WooCommerce > Payments
b. All other payment methods are hidden except for bullets. This includes WooPayments LPMs.
With the above in mind, since checkout is working with the new scoping and containers and checkout in Vendrify is now working, I think we can approve this and look at the above isssues separately if needed.
Thanks for the review and such a thorough testing, @mdmoore! 🚀 There are things with that theme that could work better, I agree. I think it would be OK to focus on fixing the critical flow, which is performing a purchase, and keep the rest part of the particular theme implementation (ideally) or as a separate issue (less preferred because I think there are limits to what we can do in terms of theme compatibility, as fixing one theme might break others). By the way, this theme is not being maintained anymore, from what I understand. The dynamic payment method filtering issue might be related to #9851, which I opened last week. It occurs even with some default testing themes. Maybe fixing this issue will fix the issue you encountered, but I'd focus first on the primary behavior and then on any potential user reports about problems with the theme. |
Fixes #7674
Changes proposed in this Pull Request
This PR creates a new div wrapper with a unique class name for WooPayments payment elements and uses it to search for elements within them. In addition, the direct targeting of WooCommerce elements has been replaced with targeting our element first and then traversing by looking at an element from that point.
This PR also fixes compatibility issue Vendrify theme had with WooPayments.
Testing instructions
Shortcode checkout
Add payment method & Pay for order
Themes
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.Post merge