I’m using Wix Velo in 2026 and need to add a product with specific variant options (Size and Pack) to the cart from a backend .web.js file for guest/visitor users.
I have tried every API available:
- wix-stores-frontend cart.addToCart → deprecated
- wix-ecom-frontend cart → crashes
- wix-ecom-backend currentCart.addToCurrentCart → crashes with “Cannot read property”
- wix-stores-backend → Cannot find module
- wix-pay-backend → Cannot find module
The simple version without any imports works fine and redirects to cart but adds the wrong variant.
My product has two options:
- Size: 2x2 inch Square, 2.5x2.5 inch Square
- Pack: Single, 5-Pack, 10-Pack, 25-Pack
Question: What is the correct 2026 Velo API to add a specific product variant to cart for a guest user from a backend file?
It’s generally encouraged to use SDKs where possible.
Can you share the code you’re using/have tried? The Cannot find module sounds like a missed import.
"Thank you! Here is the code I have tried. The issue is currentCart from wix-ecom-backend crashes with ‘Cannot read property’ when called from a backend .web.js file for guest/visitor users.
What works (but adds wrong variant):
export async function createMagnetPayment(orderDetails) {
return {
success: true,
cartId: ‘added’
};
}
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 — happens for guest/visitor users only.
How do I pass the correct Size and Pack variant so the right price shows in cart?"