Re:

There Was An Error While Updating Your Cart. Please try again

Pinball
Visitor
2 0 0

Hello.

We are getting this error when trying to add items to the cart using IOS.

Our site is: https://pinnovators.myshopify.com/

 

"There Was An Error While Updating Your Cart. Please try again."

 

I'm not a serious coder so not really able to make serious edits to our store but any help about what is causing this would be appreciated.  Everything used to work in IOS until 5-6 months ago so I'm not sure if something changed with IOS that broke Shopify.

Thanks,

Mark

@tim 

Innovation at Play!
Replies 3 (3)

tim
Shopify Partner
3911 395 1440

Have you installed any new apps?

 

Here is an explanation:

Your theme uses a jQuery library. It's a part of vendor.js asset and is version 2.2.3

It's a popular library and many apps use it too. Some apps use older versions of jQuery, some -- newer.

Nice apps check if there is jQuery loaded and if not -- load their own.

Ideally, it should happen like this:

  1. Browser starts loading vendor.js
  2. Browser starts loading Apps JS file
  3. Browser finishes loading and processesing vendor.js and jQuery is now defined
  4. App JS is loaded, checks for jQuery and uses the one loaded via vendor.js

However, since modern browsers are able to load multiple files at the same time, it may happen that the order is different: 

  1. Browser starts loading vendor.js
  2. Browser starts loading App JS file (in parallel)
  3. App JS is loaded faster, checks for jQuery (not present!) and starts loading it's own
  4. Browser finishes loading vendor.js, processes it and jQuery is now defined, however
  5. Now browser finishes loading the Apps copy of jQuery and it loads over the one vendor.js defined

Result -- theme has to use the wrong version of jQuery. 

 

This is what happens when your site is visited on the iPhone as it may be slower than desktop or IOS Safari has different loading strategy.
In your case, instead of jQuery version 2.2.3 theme has to use version 1.9.1 (loaded by Topbar -- but it's not the apps fault!). And they are not fully compatible.

 

There are several ways to fix this.
The simplest is to ensure that vendor.js is always loaded earlier than apps.

 

Try this:

  1. Make theme copy and perform the following on the copy;
  2. Open theme code for editing and find a theme.liquid in Layout folder;
  3. Search this file for line which mentions vendor.js (or vendor.min.js)

It should look similar to

  <script src="{{ 'vendor.js' | asset_url }}" defer="defer"></script>
  <script src="{{ 'theme.js' | asset_url }}" defer="defer"></script>

     4. Remove the defer="defer" from both lines

     5. Save and try your modified theme in preview.

 

The attribute instructs browsers to load this JS file later and is one of the reasons while loading sequence may be off.

By removing the attribute we instruct browser to load it immediately -- this may make it a bit less efficient, but we really want to ensure that it loads early.

 

It may be enough to remove it from vendor.js line only, but I'd recommend removing it from both just in case.

 

Finally, this may still not fix it -- I've seen Apps which are not nice and simply load their own copy of jQuery regardless -- this may need further investigation.

Hopefully in your case it would be enough.

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
Pinball
Visitor
2 0 0

Hi Tim.

Thank you for taking a look at this issue. I appreciate it!

 

After I posted this issue, I tried contacting Shopify for help. The response time to my issue was amazing! The case got escalated and Brendan helped with the issue. Here is a snippet of his response. 

 

"I have narrowed down the cause to an (app) called AAA Web Push and Announcement which has been active on your store since 2019. While you may not have made any changes to this app's settings, sometimes it's necessary for app developers to update the files that your store connects to when using their app, and it looks to me like an update on the app's side has caused this issue. It's a strange one, though disabling this app's connection to your store very definitely resolves the issue."

 

Brendan alerted the app developer to the issue, and they contacted me. I sent them a copy of your information to see if it helps them determine if they have a problem with their app. 

 

Let's see what happens!

Thanks again,

Mark

Innovation at Play!
Lubo18
Tourist
8 0 23

Any update? Same problem here with Debute theme. It started a few days ago , IOSS and Mac. Any idea which app causes this problem...