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
- 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.
- Our team found out that this bug appears randomly several times a day, except for incognito mode checkout.
- 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.
- 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‘ - We developed a script that deletes ‘lax’ tag values and parses the json strings into objects.
- A month later, we checked the number of checkout errors via TrackJS. The number of errors decreased by 5%.
Before:
After:
Have any Checkout Page Issues on Your Magento Website?