New API Missing

Trying to use the new API for adding items to a cart - import { cart } from ‘wix-stores’ ;
This API is not in the API list and gives me an error. Has anyone else experiences this?

Does it work on the site? Sometimes it is just the code checker issue (but the feature still works)

No, it does not work. I added the code right from the example in the documentation and I am getting 2 errors:

TypeError: external_wix_stores_default(…).addCustomItems is not a function

TypeError: external_wix_stores_default(…).addProducts is not a function


Here is the code copied right from the documentation

import cart from ‘wix-stores’ ;

$w . onReady ( function () {

});

export function button16_click ( event ) {
const customItems =
[{
name : “First custom item” ,
price : 10 ,
quantity : 2 ,
note : “Note for first item”
},
{
name : “Second item” ,
price : 5 ,
quantity : 1 ,
note : “Note for second item”
}];
cart . addCustomItems ( customItems )
. then (( updatedCart ) => {
// Custom items added to cart
const cartId = updatedCart . _id
const updatedLineItems = updatedCart . lineItems
})
. catch (( error ) => {
// Custom items not added to cart
console . log ( error );
});

}

export function button17_click ( event ) {
const products = [
{
“productId” : “0873ed58-f88d-77d1-4566-afd4c50d253e” ,
“quantity” : 3
},
{
“productId” : “91f7ac8b-2baa-289c-aa50-6d64764f35d3” ,
“quantity” : 1 ,
“options” : {
“choices” : {
“Weight” : “250g” ,
“Ground for” : “Filter”
}
}
},
{
“productId” : “5376f9ec-b92e-efa9-e4a1-f4f480aa0d3a” ,
“quantity” : 1 ,
“options” : {
“choices” : {
“Weight” : “500g” ,
“Ground for” : “Stovetop”
},
“customTextFields” : [{
“title” : “Custom package sticker” ,
“value” : “Enjoy your coffee!”
}]
}
}
]
cart . addProducts ( products )
. then (( updatedCart ) => {
// Products added to cart
const cartId = updatedCart . _id ;
const cartLineItems = updatedCart . lineItems ;
})
. catch (( error ) => {
// Products not added to cart
console . error ( error );
});

}

Forgot to mention:

  1. Thank you for your help
  2. I did the testing from the live site (which ignored the button click) and then got the errors using Preview in the Editor.