Add to Cart code issue

I have the following code, but it is not adding any products to my cart.

import { cart } from ‘wix-stores’ ;

$w ( “#button20kW” ). onClick (() => {
cart . addProducts ([{
“productId” : “364215376135191” ,
“quantity” : 1
}])
. then (( updatedCart ) => {
// Products added to cart
const cartId = updatedCart . _id ;
const cartLineItems = updatedCart . lineItems ;
})
. catch (( error ) => {
console . log ( error );
});
});

$w ( ‘#30kw’ ). onClick (() => {
cart . addProducts ([{
“productId” : “364215376135191” ,
“quantity” : 1
}])
. then (( updatedCart ) => {
// Products added to cart
const cartId = updatedCart . _id ;
const cartLineItems = updatedCart . lineItems ;
})
. catch (( error ) => {
console . log ( error );
});
});

$w ( “#40kW” ). onClick (() => {
cart . addProducts ([{
“productId” : “364215376135191” ,
“quantity” : 1
}])
. then (( updatedCart ) => {
// Products added to cart
const cartId = updatedCart . _id ;
const cartLineItems = updatedCart . lineItems ;
})
. catch (( error ) => {
console . log ( error );
});
});

Hi! The code you provided seems correct. It adds the same product with ID “364215376135191” and quantity 1 to the cart when the buttons with IDs “button20kW”, “30kw”, and “40kW” are clicked. It is possible that the issue is not with the code but with the configuration of your Wix store or product settings. You may want to double-check that the product with ID “364215376135191” is available in your store and that it is not out of stock or hidden. Additionally, you can try testing the code with a different product ID to see if it successfully adds products to the cart. Good luck!

Hello. I appreciate you letting me know. Unfortunetly, it is not working when I am clicking my buttons, so I was wondering why that might be?

When you say “it’s not working”, is the click event registering at all? Which piece of the code is not working and is there any error you can share

I am meaning that the button is not adding anything to the cart. It does not display an error though.

It is still not working even when I change the SKU.