From ec2929fbfcbead4370c14c552c90b424e1224357 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 3 Mar 2017 15:48:20 +0100 Subject: [PATCH] [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 --- addons/website_sale/static/src/js/website_sale.js | 13 +++++++++++++ addons/website_sale/views/templates.xml | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 894849244d5..1c61ba4da93 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -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 = ''; + 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) { diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index ac73d9d8b4b..fb65f657611 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -1097,7 +1097,7 @@