How do I refresh the cart drawer after adding an item to cart via ajax? - ajaxify shopify

jayeshcspl
New Member
4 0 0

Hi Stephen,

Did you find a solution?  I have the EXACT same issue.

 

I am using slate starter theme and ajaxify-cart.liquid.

 

Cart Drawer is not updating.  Would appreciate your help if you got it, or somebody else to help us.

0 Likes
jayeshcspl
New Member
4 0 0

Hi Alexander,

 

I am facing same issue have you find any solution? 

 

I am using slate starter theme and ajaxify-cart.liquid.  Cart count updated but Cart Drawer is not updating. after refresh cart drawer is updated. want without refresh cart drawer should update when click on add to cart button.

 

Would appreciate your help if you got it, or somebody else to help us.

0 Likes
RomFarma
New Member
4 0 0

Hy guys!
I`m facing a problem and i followed this tread and it seems you have an idea about my problem.
I`m using the free theme "Simple" and i wanted to add an "Add to cart" button to my collection list, because the theme support "Add to cart" button just in single product page.
After i followed the instructions from this thread " https://help.shopify.com/en/themes/customization/products/add-to-cart/stay-on-product-page-when-item... " from 1-9 instructions, i managed to add an "Add to cart" button on the products from the pages i wanted, but in the single product page i have the problem that when the customer clicks on "Add to cart", that button does not refresh (like the buttons that i added), and it cant add another product from that single product page, because it stays freeze saying "ADDED TO CART", until he manually refresh the page.
Can you help me to add the same button that refresh, or refresh the page itself, after a customer hit "Add to cart" from single product page?
Thanks in advance!

0 Likes
kahilkworq
New Member
1 0 0

Gday Jason, with the update step that you mentioned do you think it would be best practice to re render the cart using the Ajax response or keep the liquid cart object as your front end and find a way to update it? I’m trying to follow best practices when it comes to managing the cart, but I’m still stuck on how to refresh the token that keeps reference to the cart without reloading the page, even after adding a products, getting the new cart and calling update. Thank you! 

0 Likes
AhmedMihoub
Tourist
6 0 6

The easy way is to use the shopify custom Event cart:refresh on javascript

document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {
bubbles: true
}));

cart:refresh event refer to this function _rerenderCart :

AhmedMihoub_0-1604495948658.png

AhmedMihoub_1-1604496085237.png

 

 

it refresh the cart content with last changes
simple

AhmedMihoub
Tourist
6 0 6

Shopify expert never will tell you the solution without paying them XD but i will do it hahaha

The easy way is to use the shopify custom Event cart:refresh on javascript

 

document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {
bubbles: true
}));

 

cart:refresh event refer to this function _rerenderCart :

AhmedMihoub_0-1604495948658.png

AhmedMihoub_1-1604496085237.png

 

 

it refresh the cart content with last changes
simple

sunnyboy82
New Member
22 0 0

Hi I tried the above fix to refresh cart and now My Cart isn't showing minicart. help please. WWW.lavednerandblues.com

I might have deleted some snippit I can't tell which one. Can someone take a look as to why minicart slider stopped showing?

Thanks bunch!

Suni

0 Likes
Jyots
New Member
1 0 0

Hi Jason,

Can you guide me what I'm missing here

I need the same functionality but the theme uses handlebar.js which I m not familiar with 

this is my preview link

https://dbtpwva6xwqlbh8p-6617423.shopifypreview.com

0 Likes
garyrgilbert
Excursionist
41 3 10

unfortunately that depends entirely on what theme you are using.. it would be great if shopify made all the theme developers listen for a specific set of "general" custom events like that, but even the debut theme doesn't have the event you mentioned.. at least I couldn't find it in the theme.js file...

0 Likes
YuriEndorsi
Tourist
2 0 0

Hello, 

Currently the cart drawer is having the process of refreshing the entire page which led to closing the cart drawer. My requirement is the cart drawer shouldn't close when refreshed with the new item.  I used the shopify custom Event cart:refresh  and it worked on the Prestige Theme. I was able to add new item it refreshed without closing the cart drawer and I can see the new item.

I applied the same event code in Impulse 3.0.3 - Design and support by Archetype Themes  theme and it didn't work. I checked the function _rerenderCart in the theme.js.liquid and it isn't there. Is there any other event like the one mentioned for the Impulse 3.0.3 theme? Is there any other code that can refresh the cart content with last changes in the Impulse 3.0.3 theme? 

Any help is appreciated.

Thank you.

0 Likes