This literally just started to work at 5AM UTC only to stop working again less than an hour later without any code changes from me!!!
I honestly don’t know what is going on your velo’s side but this is obviously a server-side issue! It took more than 3 weeks to hear back from anyone, only to be told that I should be using the async functionality (which I am) and that they can’t see my side nor code because there is a password on it. Well of course there is password of it! I haven’t been able to launch it because this functionality is still broken and why would I launch something that is broken? Since I am a paying customer, at the balmy rate of 85$/month, I imagine your developers can view and debug someone’s site on the backend considering it doesn’t work in preview nor on live (until of course it decides to work and then stop again).
The cart icon IS there so there should be a cart. I even added an await to block and force the response form the cart and the cart has an id full of 0s. This is very suspicious, since for the one hour it was working, there was an actual cartID!
Please look at your server logs and fix the addToCart functionality!
The level of debugging for this paid product that I have had to do is ridiculous, and I am a software engineer for a living!
Here is one more proof that something is wrong with the cart server-side!
- Try to get the cart using the cart API:
export async function addToBagButton_click(event) {
// let me see what is in that cart
let cartresult = await cart.getCurrentCart();
...
}
- This returns. The 0s in that ID don’t look right.
{_id: '00000000-000000-000000-000000000000', buyerNote: null, appliedCoupon: null, status: 'INCOMPLETE', shippingInfo: null, …}
appliedCoupon: null
billingAddress: null
buyerInfo: null
buyerNote: null
currency: {code: 'USD', symbol: ''}
lineItems: []
shippingInfo: null
status: "INCOMPLETE"
totals: {discount: 0, quantity: 0, shipping: 0, subtotal: 0, tax: 0, …}
weightUnit: null
_id: "00000000-000000-000000-000000000000"
[[Prototype]]: Object
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
__proto__: (...)
get __proto__: ƒ __proto__()
set __proto__: ƒ __proto__()
length: 1
name: "set __proto__"
arguments: (...)
caller: (...)
[[Prototype]]: ƒ ()
[[Scopes]]: Scopes[0]
No properties
- Try to add a product using the API;
export async function addToBagButton_click(event) {
//...
const products = [{
"productId": "1a5bd1e5-c726-3772-d550-a4df6787db07",
"quantity": 1,
"options": {
"choices": {
"Size": "S",
"Color": "#F7F5F0"
}}
}]
cart.addProducts(products)
.then((updatedCart) => {
// Products added to cart successfully
console.log("Product added...");
const cartId = updatedCart._id;
const cartLineItems = updatedCart.lineItems;
console.log("cartID:")
console.log(cartId);
console.log("cartLineItems:")
console.log(cartLineItems);
})
.catch((error) => {
// Products not added to cart
console.log(error);
$w('#addToCartErrorBox').expand();
$w('#addToCartErrorBox').show();
});
}
- You get this error. It’s as if even though the cartIcon is there, the object doesn’t exist!
FetchError: {"message":"Cannot read properties of null (reading 'cartId')","locations":[{"line":3,"column":5}],"path":["cart","addToCart"],"extensions":{"code":"INTERNAL_SERVER_ERROR","exception":{"name":"ERROR:addToCart:RESOLVER_ERROR"}}}
at new e (FetchError.js:5:28)
at t.eval (fetch-wrapper.js:32:35)
at eval (tslib.es6.js:102:23)
at Object.eval [as next] (tslib.es6.js:83:53)
at a (tslib.es6.js:73:58)
- Click Wix’s “out-of-the-box” AddToCart button, which opens the Product’s QuickView.
- Select product options.
- Click Add To Cart.
- Product appears in cart, and now the cart-ID is not 0s.
{_id: '9281b5d7-68a3-4349-9a60-f96bb13753ad', buyerNote: null, appliedCoupon: null, status: 'INCOMPLETE', shippingInfo: {…}, …}
appliedCoupon: null
billingAddress: null
buyerInfo: null
buyerNote: null
currency: {code: 'USD', symbol: ''}
lineItems: [{…}]
shippingInfo: {shippingAddress: {…}}
status: "INCOMPLETE"
totals: {discount: 0, quantity: 1, shipping: 15.99, subtotal: 400, tax: 0, …}
weightUnit: null
_id: "9281b5d7-68a3-4349-9a60-f96bb13753ad"
[[Prototype]]: Object
- Now go back to step 3 and try to add a product via the cart API again, and you can successfully add a product using the cart API!!!
Either a key piece is missing from the documentation or there is a bug on the server side where it is not initializing the cart and therefore doesn’t return it.
Product added...
createConsoleProxy.ts:47 cartID:
createConsoleProxy.ts:47 9281b5d7-68a3-4349-9a60-f96bb13753ad
createConsoleProxy.ts:47 cartLineItems:
createConsoleProxy.ts:47
(2) [{…}, {…}]
0: {mediaItem: {…}, productId: 'd7388836-f53c-814f-7dcd-e6f5c4f1eda0', lineItemType: 'PHYSICAL', name: 'The Bed', notes: null, …}
1: {mediaItem: {…}, productId: '1a5bd1e5-c726-3772-d550-a4df6787db07', lineItemType: 'PHYSICAL', name: 'The Reusable Bag', notes: null, …}
length: 2
[[Prototype]]: Array(0)