What's your biggest current challenge? Have your say in Community Polls along the right column.

Add to Cart not working on custom theme, requires refresh

Add to Cart not working on custom theme, requires refresh

mraman
Shopify Partner
8 0 0

Hello!

 

We are building a custom UI on top of Shopify backend and having issues with 'Add to Cart' from our PDP. Clicking the button doesn't appear to do anything, but once we refresh the page we see that the product actually did add to the cart correctly. We have not made any changes to the cart or checkout flows, so we're not sure what the issue is. Using AJAX add API to add the product variants.

 

Any help appreciated!

Replies 6 (6)

TechWeb
Shopify Partner
5 0 0

Hi @mraman 

The thing is that the product is getting added to cart but the popup or drawer is not opening. In ajax in success add the code to open cart or cart drawer

mraman
Shopify Partner
8 0 0

Is there an example I can see for open cart / cart drawer? I'm not so sure that will work because when we open the cart drawer after clicking 'Add To Cart' there still isn't any product in there, we have to refresh the page to see it.

TechWeb
Shopify Partner
5 0 0

Which theme are you using?

mraman
Shopify Partner
8 0 0

We're building a custom UI on Lorenza theme

mraman
Shopify Partner
8 0 0

Currently the only thing that works is reloading the whole window. We've tried getting / refreshing the cart only after adding to cart, doing a get on the cart before opening it (toggle), getting the cart info and displaying the data. In this last case interesetingly when we do a get we see that the product was added to the cart, but it's not displaying in the updateCartDrawer() for some reason.

 

Any and all guidance is much appreciated!!

ballivor
Visitor
1 0 0

I'm having this issue now, were you able to find a solution?