How can Wix Studio customers create add to cart buttons that actually work?

Question:
How can I create an add to cart button, that when users click, the product is added to their cart and they are taken to the cart page?

Product:
[Which editor or feature is your question most relevant to? Wix Studio

What are you trying to achieve:
I am trying to create “Add to cart” buttons that work. Buttons that when clicked take the user to the cart page, with the product in their cart.

What have you already tried:
I tried the following code to add a delay to the button, but it isn’t working consistently.

setTimeout(function() {
// Your code to be executed after the delay of 2 seconds
}, 2000);

Below is a sample code snippet to demonstrate how you might implement this:

import wixStoresBackend from 'wix-stores-backend';
     export function addToCartWithDelay(product) {
         // Set a delay time in milliseconds (e.g., 2000 milliseconds = 2 seconds)
         const delayTime = 2000;
         setTimeout(function () {
             // Code to add the item to the cart
             wixStoresBackend.addToCart(product)
                 .then((response) => {
                     // Handle the successful addition to the cart
                     console.log("Product added to cart:", response);
                 })
                 .catch((error) => {
                     // Handle any errors during the addition
                     console.error("Error adding product to cart:", error);
                 });
         }, delayTime);
     }

Additional information:
The live website is zeroexperts.co. Sometimes when you click the buttons, the product is added to cart and you are taken to the cart page. However this is not consistent.

Wix Support have said that this requires “Velo” which I don’t know how to use unfortunately.

Unfortunately I can’t provide much help without prior Velo / JavaScript knowledge.

However you have two other options:

  1. Use the Wix Marketplace to hire a developer to implement the functionality you need in Velo: https://www.wix.com/marketplace
  2. Request this functionality on the product roadmap: Product Roadmap

Hey Anthony. I understand, I wasn’t expecting anyone to know how to help.

It seems that Wix add to cart buttons are very limited in functionality.

I’m very disappointed with Wix Studio, I’m surprised something as simple as an add to cart button doesn’t work on Wix.

Time to try Webflow / Shopify!

It doesn’t mean that this is impossible.
You just need some more coding knowledge to solve the issue.
And you will have to generate all the process in custom mode.

Hi Russian Dima!

It sounds like you agree that Wix add to cart buttons are very limited in functionality, if they need some more code to make them work.

I’m also shocked that something as simple as an add to cart button doesn’t work on Wix Studio.

For eCommerce stores that need add to cart buttons that actually work, and don’t want to custom code their sites, Wix Studio doesn’t seem to be the right solution.

Try to find your solution in one of the numerous posts about ADD TO CART …
https://forum.wixstudio.com/search?q=custom%20add%20to%20cart