Skip to main content

Numerous Magento | Adobe Commerce merchants face a problem of checkout pages that don’t load or load partially. It’s an extremely serious problem as your checkout  is the cash register of your online store. If it’s down, you make no money. In this article, we’ll describe a known Magento 2 issue, when checkout page don’t load, one of its reasons and how we solved it.

Business Issue

Checkout pages don’t load or load partially, showing the next error in the console:

Uncaught TypeError: Cannot create property ‘cart’ on string ‘{“cart”:1622105320,”directory-data”:1622105320,”ammessages”:1622105320,”freeshipping”:1622105320,”delivery_label_product”:1622105320,”
gtm”:1622105320,”shipping-message”:1622105320,”cart-tagging”:1622105320}laxlaxlax’

Solution

  1. We tried to reproduce this bug by checking out as authorized and non-authorized users in several ways: with cleared cookies/cache and using the incognito mode.
  2. Our team found out that this bug appears randomly several times a day, except for incognito mode checkout.
  3. We analyzed the error message and came to the conclusion that there was a problem with customer-data.js file and cookies. This file was getting incorrectly formatted code, so it couldn’t process it and parse the code into objects.
  4. In our case, cookies had ‘lax’ tag values at the end of code lines (lax is the SameSite tag value, which restricts
    the installation of cookies from another domain).Example:Uncaught TypeError: Cannot create property ‘cart’ on string ‘{“cart”:1622105320,”directory-data”:1622105320,”ammessages”:1622105320,”freeshipping”:1622105320,”delivery_label_product”:
    1622105320,”gtm”:1622105320,”shipping-message”:1622105320,”cart-tagging”:1622105320}
    laxlaxlax
  5. We developed a script that deletes ‘lax’ tag values and parses the json strings into objects.
  6. A month later, we checked the number of checkout errors via TrackJS. The number of errors decreased by 5%.

Before:

checkout-before-fix-600x52-1 How to fix a Checkout Page that Doesn't Load

 

 

 

After:

checkout-after-fix-600x49-1 How to fix a Checkout Page that Doesn't Load

 

Have any Checkout Page Issues on Your Magento Website?

Vladimir Repalo

Vladimir Repalo

Magento Developer at Mobecls, 8+ years of experience. Feel free to ask me anything about this post in the comments below.