Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
const addUrl = window.Shopify.routes.root + 'cart/add.js'; export default class CartModel { constructor() { ...... } addProduct(btn) { const toSend = {'items': [ id: xxxxxx, quantity: 1 ]}; fetch(addUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(toSend) }) .then(response => { .... }) .then(myBlob => { ..... }) .catch((error) => { ...... }); } }
Uncaught TypeError: Cannot read properties of undefined (reading 'routes')before I could but now I cant. I have to include something?
change
const addUrl = window.Shopify.routes.root + 'cart/add.js';
to
const addUrl = '/cart/add.js';
I could. Is it the solution?
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025