Skip to content

Commit

Permalink
fix(direct-checkout): direct checkout quick cart redirect fix.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
satyajittalukder committed Jan 8, 2024
1 parent d7084d0 commit f012fdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions Includes/Modules/FlyCart/Includes/EnqueueScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down
12 changes: 8 additions & 4 deletions Includes/Modules/FlyCart/assets/js/wfc-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
Expand Down Expand Up @@ -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();
}
);
Expand Down

0 comments on commit f012fdc

Please sign in to comment.