-
Notifications
You must be signed in to change notification settings - Fork 211
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
Place order button is disabled after re-render of payment component #2506
base: develop
Are you sure you want to change the base?
Conversation
…f payment component
Hi @rakibabu, thanks for your valuable contribution for this case, place order button is disabled as the shopper didn't select a bank yet, once the shopper select a bank, place order button will be active. Since there is no need to change, I'm going to close this one |
Hi @hossam-adyen , Thanks for testing with IDEAL, other payment methods (like giro pay) have the same problem. So there is a issue here. Please reopen this. |
Hi @rakibabu, thanks for highlight the issue with other payment methods, I left one comment, if you adapt it, this PR could be a good fix, looking forward for more contributions 👍 |
this.isPlaceOrderAllowed(false); | ||
this.isPlaceOrderAllowed(quote.billingAddress() != null); | ||
let configuration = this.buildComponentConfiguration(this.paymentMethod(), this.paymentMethodsExtraInfo()); | ||
|
||
this.mountPaymentMethodComponent(this.paymentMethod(), configuration); |
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.
How about?
this.isPlaceOrderAllowed(false); | |
this.isPlaceOrderAllowed(quote.billingAddress() != null); | |
let configuration = this.buildComponentConfiguration(this.paymentMethod(), this.paymentMethodsExtraInfo()); | |
this.mountPaymentMethodComponent(this.paymentMethod(), configuration); | |
this.isPlaceOrderAllowed(false); | |
const configuration = this.buildComponentConfiguration( | |
this.paymentMethod(), | |
this.paymentMethodsExtraInfo() | |
); | |
this.mountPaymentMethodComponent(this.paymentMethod(), configuration).then( | |
function() { | |
const hasBillingAddress = quote.billingAddress() !== null | |
this.isPlaceOrderAllowed(hasBillingAddress); | |
} | |
); |
And you need to convert mountPaymentMethodComponent()
function to be async
, and await
for adyenCheckout .mountPaymentMethodComponent
like:
mountPaymentMethodComponent: async function (paymentMethod, configuration)
{
.
.
.
this.paymentComponent = await adyenCheckout.mountPaymentMethodComponent(
self.checkoutComponent,
self.getTxVariant(),
configuration,
containerId
);
Hi @hossam-adyen, Thank you for brainstorming on this issue. There were still some edge cases, and they have been resolved with your suggestions. |
function() { | ||
const hasBillingAddress = quote.billingAddress() !== null | ||
this.isPlaceOrderAllowed(hasBillingAddress); | ||
} |
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 ran across this issue while debugging why isPlaceOrderActionAllowed
was false for a non-Adyen payment method and I tried your solution.
I'm getting Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'isPlaceOrderAllowed')
.
Switching the callback to an arrow function retained the proper this
context and resolved the TypeError.
function() { | |
const hasBillingAddress = quote.billingAddress() !== null | |
this.isPlaceOrderAllowed(hasBillingAddress); | |
} | |
() => { | |
const hasBillingAddress = quote.billingAddress() !== null | |
this.isPlaceOrderAllowed(hasBillingAddress); | |
} |
Thanks for this PR! I can confirm this is still an issue on the 9.5 version of the module |
@hossam-adyen I can confirm this is still an issue in the most recent module. The proposed fix solves the issue and make the place order button usable again. |
Description
There is a bug in the checkout that prevents people from clicking the place order button when the customer makes a modification in the shipping method or details (see video). The button is by default disabled, even though there is a saved active state for a payment method.
Tested scenarios
Schermopname.2024-02-06.om.12.06.55.mov
Fixes
This code fix ensures that when the component is re-rendered, it checks whether a billing address is set. If it is set, the button is activated. This check is necessary because no onchange event is triggered.