[FIX] website_sale: disable the checkout confirm button on submit

On the checkout page, the page loaded after clicking on the
confirm button can take a while, for instance
if you have delivery carrier API requests to perform
(Fedex, USPS, UPS, ...) in order to get
their price according to the shipping weigth
and destination.

As it took a while, the end user was therefore tempted to submit the form
again, multiple times, which caused the requests to the delivery
carriers API to be performed multiple times, and it was
monopolizing multiple workers and the overal performance of the
server was impacted. It also leaded to concurrent update due
to the fact the sale order was being updated multiple times.

opw-710963
This commit is contained in:
Denis Ledoux
2017-03-03 15:58:05 +01:00
parent a9b8bbac48
commit ec2929fbfc
2 changed files with 14 additions and 1 deletions
@@ -225,6 +225,19 @@ $('.oe_website_sale').each(function () {
$('.oe_website_sale .a-submit, #comment .a-submit').off('click').on('click', function (event) {
if (!event.isDefaultPrevented() && !$(this).is(".disabled")) {
$(this).closest('form').submit();
if ($(this).hasClass('a-submit-disable')){
$(this).addClass("disabled");
}
if ($(this).hasClass('a-submit-loading')){
var loading = '<span class="fa fa-cog fa-spin"/>';
var fa_span = $(this).find('span[class*="fa"]');
if (fa_span.length){
fa_span.replaceWith(loading);
}
else{
$(this).append(loading);
}
}
}
});
$('form.js_attributes input, form.js_attributes select', oe_website_sale).on('change', function (event) {
+1 -1
View File
@@ -1097,7 +1097,7 @@
</div>
<div class="clearfix">
<a href="/shop/cart" class="btn btn-default mb32"><span class="fa fa-long-arrow-left"/> Return to Cart</a>
<a class="btn btn-default btn-primary pull-right mb32 a-submit">Confirm <span class="fa fa-long-arrow-right"/></a>
<a class="btn btn-default btn-primary pull-right mb32 a-submit a-submit-disable a-submit-loading">Confirm <span class="fa fa-long-arrow-right"/></a>
</div>
</div>
<div class="col-lg-offset-1 col-lg-3 col-md-3 text-muted">