Cart Validation Script
Stop Shopify customers seeing blank prices or images for custom products in the cart. Learn what the script does, how it works and how to adapt it.
This script solves a timing issue in Shopify where custom product images and prices don't load immediately when items are added to the cart. Without this solution, customers might see incomplete product information (missing images, $0 prices or blank titles), which could lead to confusion or checkout errors.
What it does
Detects when custom products (marked with the
_mmqProductproperty) are added to the cartChecks if critical product data is missing (price, image, title, product ID or URL)
Displays a user-friendly overlay with a loading message to prevent interaction with incomplete data
Continuously polls Shopify's cart API every 6 seconds until all product information is fully loaded
Automatically refreshes the page once complete data is available
Problem it solves
Shopify's backend processing for custom products can be delayed, causing a gap between when a product is added to the cart and when its full details (especially images and pricing) become available. This script bridges that gap by:
Preventing customers from seeing or interacting with incomplete product data
Ensuring accurate pricing and product information before checkout
Providing clear feedback that the system is working ("We are creating your custom product...")
Automatically resolving the issue without requiring manual page refreshes
How it works
When products are added to the Shopify cart, they receive a _mmqProduct property. The script checks for this property to determine if it should run:
First, it verifies whether the cart contains products with the
_mmqProductproperty.If found, it checks whether these products are missing critical data β specifically price or image information (configurable via variables at the start of the script).
When missing data is detected, the script displays an overlay on the cart page to prevent user interaction.
It then waits for Shopify to finish processing the product data, checking at customisable intervals until the information is complete.
This ensures customers don't proceed with incomplete product information in their cart.
Configurable variables
You can change these variables at the start of the script:
1
checkPrice
true
Treat a missing or zero price as missing data.
2
checkImage
true
Treat a missing image as missing data.
3
waitTime
6000
How often the script checks the cart again, in milliseconds.
Code
Related articles
Was this helpful?