From dd83f7261ea04a9d2f45d861526d9c6d174e1353 Mon Sep 17 00:00:00 2001 From: Peter Larsson Date: Sun, 11 Jun 2023 21:01:47 +0200 Subject: [PATCH] fix: prevent creation of multiple orders (#42) --- assets/js/ledyer-checkout-for-woocommerce.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/ledyer-checkout-for-woocommerce.js b/assets/js/ledyer-checkout-for-woocommerce.js index 373717b..0485b1a 100644 --- a/assets/js/ledyer-checkout-for-woocommerce.js +++ b/assets/js/ledyer-checkout-for-woocommerce.js @@ -372,6 +372,8 @@ jQuery(function ($) { } }); + sessionStorage.removeItem('ledyerWooRedirectUrl'); + $.ajax({ type: 'POST', url: lco_params.submit_order, @@ -382,7 +384,7 @@ jQuery(function ($) { // { result: "success" | "failure"; refresh: "boolean", reload: boolean, messages: string; } try { if ('success' === data.result) { - lco_wc.logToFile('Successfully validated order in WooCommerce.'); + lco_wc.logToFile('Successfully created order in WooCommerce.'); const url = new URL(data.redirect); sessionStorage.setItem('ledyerWooRedirectUrl', url); @@ -449,8 +451,6 @@ jQuery(function ($) { // This means that placeLedyerOrder was called successfully already // (Due to an earlier call caused by client validation) window.location.href = redirectUrl; - } else { - lco_wc.placeLedyerOrder(); } } });