We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Cart drawer (0) products not showing when added

Solved

Cart drawer (0) products not showing when added

manucurette
Tourist
4 0 2

Hi everyone,

 

So, since I bought the header 10 from section store, I've been having a few issues. Current one is the following: my cart drawer in the header, always shows (0), regardless of how many products have been added. 

However, when I click "add to card", it says next to the button "1 added to cart", but icon remains (0). Then, when I click on the cart icon, it shows its content and when I leave the cart page, then the icon finally displays (1).

 

What should I do? 

I tried maaaany things in the code but couldn't fix it 

 

Capture d’écran 2025-06-20 à 17.37.22.png

 

Website: https://manucurette.com 

 

Thank you for your help

 

 

Accepted Solution (1)

tim
Shopify Partner
4812 598 1733

This is an accepted solution.

When you add items to cart, theme Javascript communicates with Shopify server and update information on the page.

However, because your header structure has changed with new section, theme JS can't find elements it expects to update and fails.

I guess, Sections Store has something like "change your cart type to Page when installing this section" in description to alleviate this.

This, however would make customer experience worse.

 

It is possible to work this problem around.

Create a "Custom liquid" section in the Footer section group. Paste this code:

<script>
document.addEventListener('click', (evt)=>{
  let el = evt.target.closest('[name=add], quantity-popover ');
  if (!el) return;
  setTimeout(()=>{
    fetch(Shopify.routes.root+'cart.js')
    .then(response => response.json())
    .then(response => {
      console.log('Cart count: ' + response.item_count);
      document.querySelectorAll('.cart-count-bubble span').forEach(e=>{
        e.innerHTML = `(${response.item_count})`;
      });
    })
    .catch(e => {
      console.error(e)
    });
  }, 1000);  
}, {capture:true, passive:true});
</script>

 

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com

View solution in original post

Replies 5 (5)

Moeed
Shopify Partner
7764 2082 2567

Hey @manucurette 

 

I'm guessing the cart quantity isn't getting updated live and you need to refresh the page to see the updated cart quantity, you probably will have to make some code changes in your header file where your cart quantity is located at so that the quantity gets updated live, since it's not only possible with CSS only so if you're not familiar with coding then I would highly recommend you to hire a Shopify developer who can help you out with that.

 

Feel free to connect with me and I would be more than happy to fix that for you,

 

Best,

Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


Guleria
Shopify Partner
4299 825 1189

Hello @manucurette ,

 

Well I think you should ask the section store about it.

btw if you are good with code then try to find the theme atc button ajax code. Once found go to its success function  and trigger the header cart icon with ajax so it displays the correct count at the same time.

 

Regards
Guleria

- Elevate Your Store with Expert Shopify Services. Email: guleriathakur43@gmail.com - Need a quick fix or a tailored customization? I’ve got you covered.
- Looking to enhance your pages? Try GEMPAGES- a powerful drag & drop page builder.
- Let’s make your store stand out. Get in touch today!
- My Apps: Productify Groups – Smart product grouping made easy.

Robert_Kanaan
Shopify Partner
105 12 25

They need to be coupled using AJAX. Implementation will vary based on theme being used. If it was working before the new section was purchased, you can likely recycle the native theme functionality to achieve it.

https://community.shopify.com/c/shopify-scripts/add-to-cart-function-how-to-update-ajax-cart-without...

https://shopify.dev/docs/api/ajax/reference/cart#bundled-section-rendering

 

Contact the Section developer for support. If not an option, seek a developer to assist.

Robert Kanaan | Shopify Developer & eCommerce Consultant
GoVedia LLC
robert@govedia.com
govedia.com

tim
Shopify Partner
4812 598 1733

This is an accepted solution.

When you add items to cart, theme Javascript communicates with Shopify server and update information on the page.

However, because your header structure has changed with new section, theme JS can't find elements it expects to update and fails.

I guess, Sections Store has something like "change your cart type to Page when installing this section" in description to alleviate this.

This, however would make customer experience worse.

 

It is possible to work this problem around.

Create a "Custom liquid" section in the Footer section group. Paste this code:

<script>
document.addEventListener('click', (evt)=>{
  let el = evt.target.closest('[name=add], quantity-popover ');
  if (!el) return;
  setTimeout(()=>{
    fetch(Shopify.routes.root+'cart.js')
    .then(response => response.json())
    .then(response => {
      console.log('Cart count: ' + response.item_count);
      document.querySelectorAll('.cart-count-bubble span').forEach(e=>{
        e.innerHTML = `(${response.item_count})`;
      });
    })
    .catch(e => {
      console.error(e)
    });
  }, 1000);  
}, {capture:true, passive:true});
</script>

 

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com

TheUntechnickle
Shopify Partner
555 66 162

Hi,

 

Your cart count issue is a common Shopify problem where the header cart icon doesn't update when items are added via AJAX. The count only refreshes when you actually visit the cart page.

 

The fix involves adding a small JavaScript function that updates the cart count element after items are added. We need to find your cart count element in the header code and make sure it gets updated when the add to cart event fires.

 

We'd love to fix this for you completely free. It's a quick 5-minute fix once we locate the specific code in your theme files. Just send us access and we'll get it working properly right away.

 

Let us know if you'd like us to handle this for you.

Best regards

Shubham | Untechnickle

Helping for free: hello@untechnickle.com


Don't forget to say thanks, it'll make my day - just send me an email! 


Get Revize for Free | Let your shoppers edit orders post-purchase | Get Zero Support Tickets | #1 Order Editing + Upsell App