Updates to cart object not persisting from within checkout page

Highlighted
Shopify Partner
2 0 1

Hello, I am making an update to the cart.note via making a post request to /cart/update.js while on the checkout page.

This works normally, however, if a customer adds a discount code after making this update (which regenerates the {{ content_for_layout }} portion of the page), the cart object reverts to how it was when the customer landed on the page.

Has anyone run into this as well? (And found any kind of workarounds?)

Thank you,

Aaron

 

1 Like
Highlighted
Shopify Expert
9926 103 1765

A bunch of questions to start us off for context building.

  • I assume this is a Shopify Plus store correct?
  • What is the update you're making?
  • How did the customer get to the cart? Online storefront, buy button, storefront API, channel, etc.
  • Have you ensured the checkout domain matches the store domain?
★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Shopify Partner
2 0 1

Hey Jason, thanks for taking an interest.

1. Yes Shopify Plus store

2. The call I am making is (with var cartNote being defined earlier).

$.post(window.location.origin + '/cart/update.js', {note: cartNote}, 'json');

This call works and doing a get request to /cart.json at this point in time would return the new note being correct. (The issue again being if someone is to add a discount code at this point in time, the cart.note reverts back to whatever it was originally.)

3. Normal online storefront flow.

4. Yes, checkout domain is matching store domain.

In the grand scheme of things, I'm wondering if it is considered bad practice to edit the cart object while on the checkout page. But it would be great to nail down some specific details as to why it would be a bad idea to explain to client.

0 Likes
Highlighted
Shopify Partner
1 0 0

Did you have any luck with this? I am trying to update the Checkout attributes once a person has moved to checkout.

0 Likes
Highlighted
Excursionist
13 1 0

Having exactly the same issue, did you find any way to solve this?

Regards.

0 Likes