AddToCart bugging?

Hi, I tried to update of my page using the AddToCart function but it’s not working anymore. Is there an issue going on with it?


Whenever I’m using the function, first time I press the button it doesn’t work, second time it adds 6 to 14 items.

Then for personalised products it doesn’t work at all. :frowning: please help!

Hi, can you please confirm if there is a bug going on?

Many thanks


Please share a link to your site or the code you’ve been using so one of us, the WixCode team, can inspect it and provide you with a solution.


Hi Doron,

Can I send you my editor url ? Would it be enough for you to access?

If not, here’s the code:

“$w(”#button5").onClick( () => {
if ($w(“#dropdownlength”).valid && $w(“#dropdownwidth”).valid && $w(“#dropdownthick”).valid) {
“choices”: {
“Deck Color”: deckcouleur, “Bottom color”: bottomcouleur, “Fin option”: fincouleur},
“customTextFields”: [ {
“title”: “Length”,
“value”: $w(‘#dropdownlength’).value
“title”: “Width”,
“value”: $w(‘#dropdownwidth’).value
“title”: “Thickness”,
“value”: $w(‘#dropdownthick’).value
“title”: “Logo:”,
“value”: $w(‘#logocolor’).value
“title”: “Pinline”,
“value”: $w(‘#pinline’).value
} )
.then( () => {
console.log(“Product added”);
} )
. catch ( (error) => {
} );
} else {
} );"

I also had created a video for support ticket initially:

Hi, do you have any news please? Just to know if I should try something else or if it’s a bug I should wait for?

Hey mate!

I’ve looked into your site and these are my findings:

  1. The #button5 seems to work well and as expected.
    I can’t find anything wrong with it so if you encounter anything please do report and try to bring
    up an example.

  2. As for #button7, it seems like inside the _click event that you’ve created, you called again an
    .onClick event (recursion) which is probably what makes the function to be delayed and add
    multiple items to the cart.

Your code should look something like this:

export function button7_click(event, $w) {
    .then( () => {
        console.log("Product added");
    } )
    .catch( (error) => {

Let me know if it worked for you!


@doron-alkalay Hi Doron!

I just tested both again, and they both add products now, but the last test I made they were both adding two articles ! Even after that correction I have made.

Just checked again the code I can’t find what’s wrong :frowning:


@mathieujamet Heya!

Found few more issues with the page.

  1. In your #button5 properties you seem to have an existing event but no function in the code editor.

  2. Your #button5 's onClick event is inside the ‘onReady’ function. I’d recommend to separate the two and actually put the onClick in the event from section 1.

Yet, after testing those changes myself the addToCart function is still behaving unexpectedly and so we’ll look into it and provide you with a solution as soon as we find out what seems to be the issue.


@doron-alkalay Hi Doron, Hope you are well. Any news on this issue?
Many thanks!!

@mathieujamet Hi!

It seems like it is working as expected now, both buttons.
Let me know if you encounter any more issues with it!


@doron-alkalay Hi Doron, Thanks a lot…!! it does work now, but it seems there is an issue when adding options. When I custom it I get the message “undefined” when it used to work fine before - maybe I need to change my code, I will try a few things and let you know.

@doron-alkalay Hi Doron!
Just to inform you I managed to make everything work again! I am finally going to be able to create the custom forms of the other boards :wink:
Many thanks for your support.


@doron-alkalay Are you able to post the code that ended up working for this issue? I’m having a similar problem, but struggling to resolve. Thanks!

1 Like