From f012fdcfabfed22b25af0f0139a726253d77344b Mon Sep 17 00:00:00 2001 From: Satyajit Talukder <65698588+gooyeduck@users.noreply.github.com> Date: Mon, 8 Jan 2024 17:17:56 +0600 Subject: [PATCH] fix(direct-checkout): direct checkout quick cart redirect fix. In the commit before the fix when the Direct checkout is being clicked. After the fix the page is being redirect to the checkout page. resolves: Direct checkout problem through quick cart #356 --- Includes/Modules/FlyCart/Includes/EnqueueScript.php | 1 + Includes/Modules/FlyCart/assets/js/wfc-script.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Includes/Modules/FlyCart/Includes/EnqueueScript.php b/Includes/Modules/FlyCart/Includes/EnqueueScript.php index 099d9da9..fc3284cd 100644 --- a/Includes/Modules/FlyCart/Includes/EnqueueScript.php +++ b/Includes/Modules/FlyCart/Includes/EnqueueScript.php @@ -189,6 +189,7 @@ private function frontend_widget_script() { 'checkoutRedirect' => $is_checkout_redirect, 'quickCartRedirect' => $is_add_to_qcart_redirect, 'cartLayoutType' => $cart_layout_type, + 'checkoutUrl' => wc_get_checkout_url(), 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'sgsb_frontend_ajax' ), 'isPro' => is_plugin_active( 'storegrowth-sales-booster-pro/storegrowth-sales-booster-pro.php' ), diff --git a/Includes/Modules/FlyCart/assets/js/wfc-script.js b/Includes/Modules/FlyCart/assets/js/wfc-script.js index 2f97ae93..340d5a3e 100644 --- a/Includes/Modules/FlyCart/assets/js/wfc-script.js +++ b/Includes/Modules/FlyCart/assets/js/wfc-script.js @@ -181,7 +181,7 @@ jQuery(".wfc-overlay").removeClass("wfc-hide"); jQuery(".wfc-widget-sidebar").removeClass("wfc-slide"); setDynamicHeight(); - getCartContents(); + openCheckoutPageCallback(sgsbFrontend?.checkoutUrl); }, error: (error) => console.log(error), }); @@ -218,12 +218,16 @@ var quantityInput = $(this).siblings(".quantity").find(".qty"); var maxValue = quantityInput.attr("max"); var currentValue = parseInt(quantityInput.val()); - - if (!isNaN(currentValue) && !isNaN(maxValue) && currentValue >= maxValue) { + + if ( + !isNaN(currentValue) && + !isNaN(maxValue) && + currentValue >= maxValue + ) { showNotification("Stock limit reached"); return; // Stop further execution if the limit is reached } - + updateProductQuantity.bind(this, "plus").call(); } );