-
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 ECE not working without WooPay #8905
Conversation
The Stripe element adjust to its container, if the container element does not have height it will not display the Stripe Express element. The changes here make sure the Stripe element will always render.
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: +5 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
wp_add_inline_script( | ||
'WCPAY_EXPRESS_CHECKOUT_ECE', | ||
" | ||
var wcpayConfig = wcpayConfig || JSON.parse( decodeURIComponent( '" . esc_js( $wcpay_config ) . "' ) ); |
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.
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.
We can remove this if
block since the wcpayConfig
variable declaration already handles the possibility of it being set, with var wcpayConfig = wcpayConfig || ....
.
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.
@rafaelzaleski the problem is that the variable is printed twice in the frontend.
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.
That's a valid point. I also feel uncomfortable having a condition related to WooPay within the ECE code, as they are distinct entities.
However, we could remove the wcpayConfig
dependency in expressCheckoutElementPaymentMethod
because the component won’t even be registered if the ECE feature flag is disabled (see this code).
[...]
const expressCheckoutElementPaymentMethod = ( api ) => ( {
[...]
canMakePayment: () => {
if ( typeof wcpayExpressCheckoutParams === 'undefined' ) {
return false;
}
return true;
},
[...]
If we remove the dependency, setting a minimum height for the container might be enough. What do you think?
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.
That's a great idea. I've update the code.
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.
@rafaelzaleski Done a3760ec
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.
The code looks good, and I couldn’t find any regressions in the tests. Thank you for addressing this, @asumaran.
My only concern, which doesn’t need to be resolved in this PR, is about scenarios where ECE is the sole express checkout payment method. If <Elements>
doesn’t render anything, we could end up with an empty express checkout section on the checkout page. 🤔 I'll keep track of this for future investigation.
Changes proposed in this Pull Request
Fixes the Express Checkout element not working without WooPay.
Testing instructions
Follow testing instructions from #8884
wp option update _wcpay_feature_stripe_ece 0
). Payment Request buttons should work as expected.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