Hi all, I am working on a Product Configurator. Therefore I have created a dynamic page of the product page. In the normal Product Page, it is possible to add the product to the cart (with the set options already in the database collection).
Now in the dynamic page, I am using a 2nd collection with references the product and adds options. And a 3rd collection referencing customizations of the options (e.g. option1 has 4 colors to choose from)
Is it possible to add this to the cart, although I don’t have every customization included in the product collection? If yes, can someone help me, I am terribly failing.
I have tried these 3 versions of the addtocart function:
export function addToCartButton_click ( event , $w ) {
cart . addProducts ([{
‘productId’ : productId ,
‘quantity’ : 1 //,
// ‘options’: { choices: selectedOptions }
}])
}
const products = [{
“productId” : “9a6c00d3-aac8-9959-a26e-43bbf982ac12” ,
“quantity” : 1 ,
“options” : { “choices” : selectedOptions }
}]
export function addToCartButton_click ( event , $w ) {
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 );
});
}
export function addToCartButton_click ( event , $w ) {
$w ( ‘#shoppingCartIcon1’ ). addToCart ( productId , 1 , { choices : selectedOptions } );
}
The “selectionOptions” is an array of the selection options
The productId always is 9a6c00d3-aac8-9959-a26e-43bbf982ac12
The console return either is nothing or:
Now my question: is it even possible to have a addtocart function in a dynamicPage and where does the new productID " 687dac9f-c5ee-4b6d-bd3e-8040923e3bec" come from? I never defined it anywhere and there also is no product with this ID.
Thanks in advance