Hi everyone,
I am running into a frustrating issue with the wix-stores-backend API and hope someone can shed some light on this.
The Scenario:
I have a custom product configurator. Upon adding to the cart, I first save the configuration data into a Wix Collection (SavedDesigns) to get an ID. Then, I try to add the product to the cart using cart.addProducts(), passing this ID into a Custom Text Field (customTextFields) so I can reference the design later.
The Problem:
The product is successfully added to the cart (Promise resolves, console logs success). However, the Custom Text Field (“Design-ID”) remains completely empty in the cart, checkout, and order dashboard. It acts as a “silent fail” — no error is thrown, the data is just dropped.
What I have verified:
- The
titlein the code (“Design-ID”) matches the field name in the Product Dashboard 100% (checked for spaces/typos). - I tried creating a fresh product to rule out legacy database corruption.
- I logged the payload right before sending: The
valueis definitely there (a valid string). - Even hardcoded values (e.g.,
value: "TEST") do not show up.
My Suspicion:
Is there a known breaking change with cart.addProducts regarding how Custom Text Fields are mapped on the new Wix eCom infrastructure? Does the API now require a specific Field ID instead of the Title?
Here is the backend code I am using:
import { cart } from 'wix-stores';
import wixData from 'wix-data';
const HOODIE_ID = "1234";
const ZIP_ID = "1234";
$w.onReady(function () {
$w("#html1").onMessage(async (event) => {
if (event.data.type === 'addToCart') {
const data = event.data.payload;
console.log("Receiving data, saving to DB...");
const designEntry = {
configText: data.field1,
detailsText: data.field2,
price: data.price,
screenshot: data.screenshot,
createdDate: new Date()
};
try {
const savedRecord = await wixData.insert("SavedDesigns", designEntry);
const designId = savedRecord._id;
console.log("Saved to DB. ID:", designId);
const productId = (data.type === 'hoodie') ? HOODIE_ID : ZIP_ID;
const logoChoice = data.hasLogo ? "Ja" : "Nein";
const productsToAdd = [{
productId: productId,
quantity: 1,
options: {
choices: {
"Größe": data.size,
"Innenfutter": data.lining,
"Logo-Aufpreis": logoChoice
}
},
customTextFields: [
{
title: "Design-ID",
value: designId
}
]
}];
await cart.addProducts(productsToAdd);
console.log("Success: Added to cart (but text field likely empty)");
$w('#html1').postMessage({type: 'success'});
} catch (error) {
console.error("ERROR:", error);
$w('#html1').postMessage({type: 'error', msg: "Cart Error"});
}
}
});
});
Has anyone experienced this behavior recently? Any workaround?
Thanks!
