facebook_pixelimg

Welcome to Our Help Desk.

You will get all the detailed information for your queries related to our Shopify apps.

Steps for Customer Accounts Required on Checkout Settings.

Eye icon5972 Views Watch iconNovember 11, 2021

When you set the Customer accounts required for checkout and if the user does not log in and hit the checkout then Shopify will redirect the user to the login page.

And after login, Shopify will redirect the user to the Checkout. It is auto-redirect by Shopify so in this case, the automatic discount is not applied at the checkout.

In this situation, We have to redirect them to the cart page when they log in and prevent the auto-redirect to the checkout.

Below is the code which you have to add to the “customers/login.liquid” template.

<script>
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
return false;
};
var autoredirect = getUrlParameter('checkout_url');
if(autoredirect != ''){
if(document.querySelector('form[action="/account/login"]') != null){
document.querySelector('form[action="/account/login"]').insertAdjacentHTML('beforeend', '<input name="checkout_url" type="hidden" value="/cart" />');
}
if(document.querySelector('form[action="/account"]') != null){
document.querySelector('form[action="/account"]').insertAdjacentHTML('beforeend', '<input name="return_to" type="hidden" value="/cart" />');
}
}
</script>

Like below screenshot:

Submit Your Query