Update cart count using AJAX APIs without refreshing the page

Abhilash
Shopify Partner
56 0 3

Hi. 
Browsing across various posts, I've seen that people are updating the cart count using .html(cartcountvalue). However, this isn't a scalable solution since different Shopify themes have different names in their HTML tags.
Example, Shopify's default theme has an attribute called CartCount. However, in other themes, this name is different.

So, what would be the best possible way to update the cart count on a Shopify store without refreshing the page?

Replies 7 (7)
Dan_Webb
Excursionist
45 0 13

Hey Abhilash, Is this the same question as you asked here https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/generic-approach-to-update-cart-count-... and Jason answered?

Essentially, there is not currently a consistently reliable and enforced way across all stores to apply updates to the cart count. One approach may be to look at targetting the majority of themes then if that fails fall back to using Jason's suggestion which was to provide instructions within the app.

Abhilash
Shopify Partner
56 0 3

Hey Dan, pardon me for this.
Yes, I'll do as you and Jason have suggested. Thanks.

Catherinalm
New Member
6 0 0

Hi there,

 

I have the same issue. When I enter the website I don't see the cart count until I add another item in the cart. Is it possible to guide me and explain me where to pu Jason recommendation?

 

Thanks! 

PaulNewton
Shopify Partner
4211 303 902

@Catherinalm each theme is different you'll get further by providing your store name,theme, and storefront password if locked.

 

If you made any changes to your theme try and old version and see if the problem is still there.

If you just recently got your theme contact that themes support if the cart count is bugged.

If you recently added an app then this problem happened contact that apps developers.

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
sillycube
Shopify Partner
694 16 101

Any update after 3 years? I still don't find a way to update cart without page refresh 😞

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
PaulNewton
Shopify Partner
4211 303 902

@sillycube wrote:

Any update after 3 years? I still don't find a way to update cart without page refresh 😞


@sillycube The topic is not about updating carts, it's about changing cart count INDICATORS and that more than likely will NEVER be a standard interface for changing the cart count indicators for ALL themes per my previous post.

If you need to hydrate|update a /cart template on the frontend with the new state based on the cart contents use the sections rendering api, or just ajax and a custom template consuming /cart.json.

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
sillycube
Shopify Partner
694 16 101

@PaulNewton OK, thanks for your prompt reply

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview