Debut Theme - Stop 'Add to Cart' from directing to cart page

Tourist
5 0 2

Hi Shopifyers.

I'm currently using (and enjoying) the Debut theme. Unfortunately, when a featured product (ie on the home page) is added to cart it automatically takes you to the cart page. I'd like to stop this from happening.

I followed the steps in this article re ajax implementation with no luck.

Any assistance would be greatly appreciated! Thank you for your time.

Site: travelessentialz.com

1 Like
Tourist
5 0 2

BUMP

0 Likes
Excursionist
24 0 12

I'm also needing a solution to this. Should it work... or is it inherently broken?

0 Likes
Excursionist
24 0 12

Ok, I've solved a few of the problems. First thing is that Debut doesn't come with jQuery by default.

Add the following to your theme.liquid file just above `{% include 'ajaxify-cart' %}`:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

Then search the ajaxify-cart.liquid file for `.size()` and replace it with `.length` (the provided code uses an outdated peice of jQuery).

Finally, in the same file, update the reference to the cart count. Change:

Shopify.AjaxifyCart.init();

To:

Shopify.AjaxifyCart.init({ cartCountSelector: '#CartCount span' });

That should now work with Debut.

 

2 Likes
Excursionist
24 0 12

One more thing, you will also want to go to header.liquid and change the line:

{% if cart.item_count > 0 %}

To:

{% if cart.item_count > -1 %}

This will ensure that the shopping cart amount is always visible, so it can be manipulated by ajax.

1 Like
Tourist
5 0 2

Absolutely outstanding Johnny! Worked perfectly.

Thank you.

0 Likes
Shopify Expert
9807 92 1560

First thing is that Debut doesn't come with jQuery by default.

It does. v2.2.3 is the current version included.

It's found in vendor.js so there should not be the need to add it again. It's possible that you'll create other issues by doubling up on it.

 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Tourist
5 0 2

Hi Jason,

Could you suggest a different solution?

0 Likes
Excursionist
24 0 12

Jason is right. I didn't realise that vendor.js harded coded lots of libraries into one file. Ugh.

Instead of adding another jQuery, you can also remove defer='defer' from theme.liquid on line 60, so it reads:

<!--[if (gt IE 9)|!(IE)]><!--><script src="{{ 'vendor.js' | asset_url }}"></script><!--<![endif]-->

This will allow 'ajaxify-cart' to see jQuery.

Another option is to remove the older version of jQuery from vendor.js.

Other than that, you'd have to hack into ajaxify-cart.

2 Likes
New Member
1 0 0

I have followed both the shopify page and then the additional items here and i'm not getting any result. It's just adding to cart then redirecting. Any other ideas?

0 Likes