Resolved: Cart not updating after checkout

Tourist
18 0 2

Hi Guys,

after a checkout on our store the cart stops updating. What I mean to say is that initially everything works fine, products can be added to the cart and the checkout process goes smooth. However if I go back to the store after checkout and try to add more products to the cart they will not add. This problem persists until I clear the browser cookies. So I'm assuming it's an issue with the session. I'm adding products with the AJAX api as follows:

$.ajax({
  type: 'POST',
  url: '/cart/add.js',
  dataType: 'json',
  data: data,
  success: Shopify.onSuccess,
  error: Shopify.onError
});

Any fixes?

 

 

UPDATE: Found the Fix!

Hey I figured out the issue!

It was nothing to do with either my code, or with Shopify – it was CloudFlare. We use CloudFlare as our DNS host because it’s interface is awesome, it’s free, and you can take advantage of its special CDN capabilities to speed up web traffic. Learn more here if you are interested: https://support.cloudflare.com/hc/en-us/articles/205177068-Step-1-How-does-CloudFlare-work-

However, it appears in the case of Shopify, the CDN capabilities cause issues with the session cookies. So for now I’ve easily toggled them off in CloudFlare. It would be cool though if this worked. Maybe Shopify devs can set up a free CloudFlare account and test it out – if they can ever find time in their very likely super busy schedules! :)

Hopefully this can be logged as a known issue for any future customers experiencing this problem.

1 Like
Shopify Expert
9807 92 1560

That's a little hard for forum members to test since you're running a live gateway, processing real money.

However if I go back to the store after checkout and try to add more products to the cart they will not add. 

Care to shed more detail on will not add?

  • Doesn't fire the code,
  • Appears to fire code nothing happens
  • Redirects to cart, nothing added
  • etc.

Have you checked the browser debug console to see if any errors are being reported?

 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Tourist
18 0 2

The ajax request from jQuery comes back with a 200 response as successful, but no items actually get added to the cart.

1 Like
Shopify Expert
9807 92 1560

Are you sure you're sending data? What's the actual post and response data?

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Tourist
18 0 2

The data being sent is an object like this:

{quantity: 1, id: "3330999237"}

debug tools in chrome show the data is being sent. I tried adding a dummy product and the response header was: (which seems normal I think)

{"id":3330999237,"properties":null,"quantity":1,"variant_id":3330999237,"title":"Part 1 - White \/ Small","price":0,"line_price":0,"sku":"","grams":0,"vendor":"river ridge home products","product_id":454649292,"gift_card":false,"url":"\/products\/part-1?variant=3330999237","image":"https:\/\/cdn.shopify.com\/s\/files\/1\/0754\/3537\/products\/butterfly.jpg?v=1433518393","handle":"part-1","requires_shipping":true,"product_type":"","product_title":"Part 1","product_description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum orci justo, luctus in ipsum nec, sagittis mattis ante. Aliquam eget nulla id libero efficitur dictum. Aenean quis justo ligula. Vivamus facilisis posuere neque ut volutpat. Cras ut aliquet nisl. Praesent semper ligula diam, sit amet commodo lorem rutrum vel. Curabitur convallis elit quam. Nunc aliquam sapien vel nibh sodales placerat.","variant_title":"White \/ Small","variant_options":["White","Small"]}

However, no item ever appears in the cart. And if I go to the cart page it says it's empty. Remember, this whole process works fine until after I go through the checkout process. Then it stops working, until I clear browser cookies, then it starts working again.

Even though the site is live, we have not yet launched the store portion. You can see this issue in action by going to this page: http://www.riverridgehome.com/collections/all-parts/link:SKU123?handle=drawers ;

Add a few of the products to the cart, which should be free. Choose the free shipping option, and checkout for free. Then try to add more products to the cart, that's when the issues start.

0 Likes
Tourist
18 0 2

Hi Guys, I NEED a solution for this issue. It occurs in both Chrome and Windows 10 Edge browser. I can verify that the same happens in Firefox, IE, and or Opera if you want. But this is an issue and seems to be a problem with a session variable or something.

0 Likes
Shopify Expert
9807 92 1560

If you think it's a Shopify issue contact Support directly, carrying with you the data you've compiled on the error. I've got a few checkout related edits on my run sheet for tomorrow so if I get a chance I'll run a test to see if I can dupe the issue.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Tourist
18 0 2

I'll wait to hear from you, if you are unable to dig anything up I'll contact support. Thanks!

0 Likes
Tourist
18 0 2

Hi Jason, and/or anyone else available to help, I'm still unfortunately having this issue. I've found that Shopfiy has no official support channel to assist with AJAX API questions, I can't even pay for support sadly. Honestly this really leaves me feeling pretty disillusioned.

Anyways, I'm doing some troubleshooting on it today, I'll post back my findings, but if anyone can offer even any ideas it would be GREATLY appreciated. Thanks so much!

 

0 Likes
Tourist
18 0 2

If I fire up my browser and add products to my cart things work great. Then I complete the checkout process. Then I go back to my store and try to add products to my cart, but even though the api data being sent is correct and I get a 200 OK response from the server, no items ever show up in the cart. Then I clear the browser cookies and the items that I added but never showed up, suddenly show up! It's like a browser cookie holding my cart session is not expiring properly when the checkout is completed. Any thoughts?

0 Likes