Happening now | Office Hours: Customizing Your Theme With Moeed | Ask your questions now!

Why does updating cart item quantity return a 404 error?

Why does updating cart item quantity return a 404 error?

styleshop27
Shopify Partner
32 0 2

I am using a checkbox to add an item to a cart, and when it is unchecked, remove the item from the cart. Below is the error I am getting when trying to update the quantity of the item in the cart (removing it). 

 

POST https://mywebsite.com/cart/update 404 (Not Found)

 

I tried replacing "routes.cart_update_url" with "routes.cart_add_url" and the error changes from (Not Found) to (Bad Request) meaning the request is actually made with the add url, just the body is invalid as it is not the proper format. I can't figure out why the "routes.cart_update_url" is causing a (Not Found). 

 

Below is my JavaScript Code (protector is just a variable that holds the variant ID):

 

let updates = {
   protector: 0
};
fetch(`${routes.cart_update_url}`, {
   method: 'POST',
   headers: {
      'Content-Type': 'application/json'
   },
   body: JSON.stringify({ updates })
})
.then(response => response.json())
.then((response) => {
   this.window.SLIDECART_UPDATE(response);
})
.catch((error) => {
   console.error('Error:', error);
});

 

 

 

Reply 1 (1)

PaulNewton
Shopify Partner
7746 679 1617

https://community.shopify.com/c/hydrogen-headless-and-storefront/read-before-posting-custom-storefro... 

This is the hydrogen subforum for headless storefront architectures

Not for the online-sales channel themes.

Unless your doing something hinky with hydrogen you can report your own content to have it moved to the proper forum in the the three dot kebab menu on your post.

Either design or techQ&A.

 https://shopify.dev/docs/custom-storefronts/hydrogen/getting-started 

 

 

 

 

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org