Advanced 1 min read
Shopify's cart attribute limit
Shopify's cart attribute limit is somewhere between 19.9 MB and 20 MB, or roughly: Max attribute value size ≈ 20,873,216 characters (just under 20 MB). To test this out use the script below on your Shopify store: 413...
By Joe Pichardo •
Shopify’s cart attribute limit is somewhere between 19.9 MB and 20 MB, or roughly:
Max attribute value size ≈ 20,873,216 characters (just under 20 MB).
To test this out use the script below on your Shopify store:
413 (Payload Too Large) error will throw on the larger attribute.
const sizes = [20873216, 20900000,21000000];
(async () => {for (const size of sizes) {const largeString = 'x'.repeat(size);const attributes = { long_data: largeString };
console.log(`🚀 Trying size: ${size} characters (${(size / 1024 / 1024).toFixed(2)} MB)`);
try {const response = await fetch('/cart/update.js', {method: 'POST',headers: {'Content-Type': 'application/json','Accept': 'application/json'},body: JSON.stringify({ attributes })});
const data = await response.json();const returnedLength = data.attributes?.long_data?.length || 0;
console.log(`✅ Size ${size}: Saved length = ${returnedLength}`);} catch (err) {console.error(`❌ Size ${size}: Cart update failed`, err);}
await new Promise((res) => setTimeout(res, 1000)); // throttle-safe}})();
Discussion
Loading comments...