-
Notifications
You must be signed in to change notification settings - Fork 219
Prevent saved payment methods showing if their main method canPay
function returns false
#9917
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThe
This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
6bb4ad7
to
b68abe1
Compare
Size Change: +1.81 kB (0%) Total Size: 1.17 MB
ℹ️ View Unchanged
|
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.
Thanks for working on this, @opr. I've successfully tested the PR.
Code-wise, I could spot something strange. But I'd appreciate it if @mikejolley could double-check the code.
I just left a comment regarding one TS error that had been introduced by this PR. That said, as the PR works as expected, I'm pre-approving it.
assets/js/blocks/cart-checkout-shared/payment-methods/test/saved-payment-method-options.tsx
Outdated
Show resolved
Hide resolved
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.
Spotted nothing out of the ordinary in the code so looks good. I did not re-test the functionality.
This PR will update the code used to display saved payment methods to ensure the saved methods for a specific gateway only display if that gateway's
canPay
function is true.To achieve this, this PR introduces the following changes:
CanMakePaymentArgumentCart
- necessary because thecart
passed tocanPay
functions is a little different to the one in the data store (the keys are named differently, we can deprecate this later, but it is not in scope for the current PR)getCanMakePaymentArg
which will get the arg passed tocanMakePayment
- having this in a "getter" makes it reusable. Previously this was only needed incheckPaymentMethodsCanPay
but now it is also used when checking whether the saved methods can pay.canPay
function, if it isfalse
then do not display any saved methods for that gateway.SavedPaymentMethodOptions
to TypeScriptFixes #8678
Other Checks
Testing
Automated Tests
User-facing Testing
WooCommerce Visibility
Changelog