Wix Velo currentCart.addToCurrentCart crashes with "Cannot read property" in backend web module

5 hours ago 1
ARTICLE AD BOX

I am building a custom magnet order page on Wix using Velo. Customers select Size and Pack options, upload photos, and checkout. I have a backend .web.js file that handles adding the product to cart.

The problem is every time I import currentCart from wix-ecom-backend the function crashes with "Cannot read property". The simple version without any imports works fine.

Working code (no imports):

export async function createMagnetPayment(orderDetails) { return { success: true, cartId: 'added' }; } Broken code (with currentCart import): import { currentCart } from "wix-ecom-backend"; export async function createMagnetPayment(orderDetails) { const { productSize, packSize } = orderDetails; try { const updatedCart = await currentCart.addToCurrentCart({ lineItems: [{ catalogReference: { appId: '215238eb-22a5-4c36-9e7b-e7c08025e04e', catalogItemId: '0475cc69-da96-a229-903c-48081c5013f9' }, quantity: 1 }] }); return { success: true }; } catch (error) { return { success: false, error: error.message }; } }

Error: "Cannot read property"

How do I correctly pass Size and Pack variant options to get the correct variant price in the cart?
Using Wix Editor Velo 2026.

Read Entire Article