Cart not updating price or removing item

Hi guys, when I click the Add to Cart button, the product adds normally to the cart, but when I try to remove it or click the plus and minus buttons, the price doesn’t update. It just stays the same no matter what.

How can I fix this so the cart functions properly when I click plus/minus or remove an item?

Here’s my store, try adding it to the cart to see how it works: https://timcreator.myshopify.com/products/editing-masterclass

Thanks for the help,
Tim

Something has happened to your layouts/theme.liquid – all highlighted strings has no quotes/apostrophes/ticks:

The code should look like this – https://github.com/Shopify/dawn/blob/main/layout/theme.liquid#L333-L366.
Note that these strings use ticks – it is possible that “Format code before saving” in Shopify editor stripped them (somebody complained about this recently).

Obviously, theme JS would not work properly without these variables defined.

1 Like

So what should I do? Do you know how to fix it? I’m not a pro, so I’m pretty confused…

  1. Make sure that this checkbox is unchecked:

  1. You can either roll back your layouts/theme.liquid to older version, where the code highlighted on the screenshot looks like the one from the github link. Or, you can copy selected code from the gihub file and paste into your theme.liquid.

Make sure that you do not loose closing tags and do not create duplicate ones.

  1. After you’ve saved the file, check once again that ticks are in place and every opening quote/apostrophe/tick has a closing pair.

However, it would be good to make a theme copy first as a backup – click 3-dot button next to your theme name and “Duplicate”

1 Like

You’re a legend! It works, I replaced my file with the one from github and it works! Thank you so much, appreciate that!

1 Like

Now it may be necessary to redo the initial edit which also caused the problem.

What do you mean? It works as it should.

I mean there was a reason why you’ve edited the file and saved it. If not – all good.

1 Like

Not sure why it didn’t work before, I must’ve accidentally changed something or whatever. But it’s working now, so all good.

Hi @tim_1 I tried by editing the code with the one from github but still no luck….I’m not sure if I have the ‘automatically format liquid files on save’ checkbox unchecked, where can I find that? Thank you!

That was an old version of Shopify code editor. Probably not a problem anymore…
If you have a problem, share a link to your store.

Thank you. Yes I still have that problem. My store link is rosemoonjo.com. I removed the password.

There are some errors.
This line has a semicolon at the end in your code, while it should not:

 fetch(window.Shopify.routes.root + 'cart/change.js', { ...fetchConfig(), ...{ body } });

Also, your code uses change url, but original code uses update, probably not significant for this use case. I’d probably use code from the github unless there is a reason for this.

Since the code in this file does not run due to syntax error, there is a Javascript error in another file which depends on this one.

Fix the error above and let’s see how it goes then.

1 Like

Thanks so much! It worked

1 Like