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
Prevent users from doubleclick on Payment button #9351
Conversation
Hello @mreker! This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community! |
My fix simple disable the payment button when it is clicked, to prevent users from double click on it. I think the check-box should be disabled too, but I can't figure out how to solve this part. If the loading is very slow it is possible to uncheck terms and conditions and the recheck it - and click the now undisabled payment button again. |
Hi Mreker, Thanks for your PR. Best regards, Khouloud |
@khouloudbelguith what do you think about also disable the checkbox? |
Hi @mreker, You're modifying a generated file in this PR. |
Now it is not possible to uncheck the checkbox after click on payment button, I fixed that part too. I think this is the right behavior? wdyt @Quetzacoalt91 @khouloudbelguith |
Can this fix be added to 1.7.4.2 milestone? |
themes/_core/js/checkout-payment.js
Outdated
@@ -112,6 +112,8 @@ class Payment { | |||
confirm() { | |||
var option = this.getSelectedOption(); | |||
if (option) { | |||
$('.custom-checkbox').click(false); | |||
$('.btn-primary').prop('disabled',true); |
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.
Not sure it's the best idea to disable all .btn-primary
button when an error can occurred and block all buttons.
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.
Would you like $('body#checkout #payment-confirmation .btn-primary').prop('disabled',true);
instead?
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.
No need to chain ids. But you can use exactly the same behavior as above.
$(this.confirmationSelector + ' button').prop('disabled', true);
I think this is the only thing you need for this PR. (but not sure =))
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 have just tested your solution. I can't reproduce the error 👋 Thank you!
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 to you for your contribution ;) Don't forget you did all the job!
themes/_core/js/checkout-payment.js
Outdated
@@ -112,6 +112,8 @@ class Payment { | |||
confirm() { | |||
var option = this.getSelectedOption(); | |||
if (option) { | |||
$('.custom-checkbox').click(false); |
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.
Stopping propagation can crash some modules. a button just need to be disabled after the first click and restored in case of failure
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 need help on this please.
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 delete this line
Thank you @PierreRambaud and @Quetzacoalt91 |
@Quetzacoalt91 is it ok for you? |
Sounds good to me. However, assets have to be regenerated before the QA team can review this PR. |
@Quetzacoalt91 can this be added to 1.7.4.2? |
Prevent users from doubleclick on Payment button from #9351
Important guidelines
This change is