Swell "add to cart" button

We recently tried to integrate the swell commerce plugins on our site. To start with, it seemed that it worked well, and we were able to create a product on swell and have it appear on our page (product image, title, price). However issues arose when we tried to add the add to cart function.

We read that we needed the cart provider as the wrapper on the page for the cart component and add cart component to work. We tried a variety of combinations.

  1. We tried that “add to cart” component being within the product component (with and without the product ID - We used the product ID URL (both the hash and the name version), we used the product ID hash from swell (end of url on swell product), and the product ID we set (name) - we also tried defining the on-click interaction despite reading that it should automatically do it for the product that it the add to cart component is sitting within - none of this worked ultimately.
  2. We tried a fresh page with the cart provider at the top and all of the components with the recommended order and variations of that for troubleshooting, no luck either.

Has anyone successfully setup a shop with swell components to avoid having to use the external swell shop?

We’d love to be able to have our products working on-site and to have the user experience stay within the plasmic site.

We’re using vercel to host, if that makes any difference? I read this does not make any difference as to whether the add to cart button would work in plasmic preview (nor when hosted).

The TLDR problem: click add to cart, the cart component does not update, nothing happens

Hi @jvx4 !

Hosting on vercel shouldn’t be a problem at all, so don’t worry about it

From what I know, we have the Cart Provider component in Swell integration. Have you tried adding the Cart provider within the Product, and nesting the Add to Cart button as it’s child? You can play around with the order, i don’t remember exactly if the Product should be a top parent or the Cart provider

Also, can you send us some error logs from the console? Or the network request logs that are occurring when clicking the button.

In the meantime we will check if something has changed on swell’s end, maybe there was an API change which led to this behavior

1 Like