Solved

Why isn't my shopping bag icon taking users to the cart?

vkulynych
Tourist
3 0 0

I am having trouble with the shopping bag in the top right corner of the debut theme. It is unable to click and take you to the shopping cart. I have done some edits and put in some apps that may have caused a change to the existing themes shopping bag. If I click the shopping bag it won't take you to the shopping cart on both the desktop and mobile version.  If you press and hold the bag in the mobile version it will pop open the shopping cart.

I am still able to add items to the cart and to click the View Cart button in the popup window when adding an item to the cart.  I am wondering if anyone can assist with this? 

Accepted Solution (1)
diego_ezfy
Shopify Partner
2958 568 891

This is an accepted solution.

@vkulynych,

1. In your Shopify Admin go to online store > themes > actions > edit code
2. In your theme.liquid file, find the </body> (press CTRL + F or command + F on Mac)
3. paste this code right above the </body> tag:

 

 

<script>
function redirectToCart(){
var $cart = document.querySelector(`.site-header a[href*='/cart']`);

if (!$cart){
    return;
}

$cart.addEventListener('click', function(){

window.location.href = `https://apex-predator-brewing.myshopify.com/cart`
});
}

redirectToCart();
</script>

 

 


The code above will fix the problem, however it's just masking a deeper issue.

There is some app that is purposefully handling the "on click" events of your cart. The app seems to be from "sasquatchstudio.co".


It fails to do so on some occasions and then breaks the redirect, hence leading you to experience this bug. it's important to find out which app it is and request the devs to fix it, because it may be breaking other stuff in your theme that you are unaware of and can harm your conversions.

Kind regards,
Diego

View solution in original post

Replies 5 (5)

diego_ezfy
Shopify Partner
2958 568 891

Hello @vkulynych,

Please share:
- your store URL;
- page URL with the issue you mention;
- storefront password (if your store has one).

If the store is not online yet, please follow this quick tutorial to learn how to safely and temporarily share an offline/unpublished theme URL.

Kind regards,
Diego

vkulynych
Tourist
3 0 0

https://shop.apexpredatorbrewing.com

Our page is online.  It's every page that has an issue as it is the shopping bag itself that won't take you to the shopping cart.

 

Thank you.

diego_ezfy
Shopify Partner
2958 568 891

This is an accepted solution.

@vkulynych,

1. In your Shopify Admin go to online store > themes > actions > edit code
2. In your theme.liquid file, find the </body> (press CTRL + F or command + F on Mac)
3. paste this code right above the </body> tag:

 

 

<script>
function redirectToCart(){
var $cart = document.querySelector(`.site-header a[href*='/cart']`);

if (!$cart){
    return;
}

$cart.addEventListener('click', function(){

window.location.href = `https://apex-predator-brewing.myshopify.com/cart`
});
}

redirectToCart();
</script>

 

 


The code above will fix the problem, however it's just masking a deeper issue.

There is some app that is purposefully handling the "on click" events of your cart. The app seems to be from "sasquatchstudio.co".


It fails to do so on some occasions and then breaks the redirect, hence leading you to experience this bug. it's important to find out which app it is and request the devs to fix it, because it may be breaking other stuff in your theme that you are unaware of and can harm your conversions.

Kind regards,
Diego

vkulynych
Tourist
3 0 0

Thank you.  That fixed the shopping bag.  I have contacted the app support as well.  It is the app called Canteen - Deposits and Fees.  It handles charging for bottle deposits on purchases - adds the fee and makes it so it's automatic and not deletable if a can deposit item is in your cart.  Will I experience a shopping bag issue down the road again or will the code fix it for the long term?  I am hoping they can fix the bug in their software but I may have to find another solution for can deposits.  Any suggestions?

diego_ezfy
Shopify Partner
2958 568 891

Hey @vkulynych,

This particular code is a permanent fix to redirect the users to cart whenever they click on the shopping bag button.

Unfortunately I am unaware of any app that achieves this same functionality, I hope you can find one soon and/or that they fix this issue in their app as well. It could be worthwhile asking it here in the community, someone else may know an alternative.

Wishing you all the best.

Kind regards,
Diego