# Add to cart button

**URL:** <https://community.weweb.io/t/add-to-cart-button/866>\
**Category:** How do I?\
**Created:** [July 25, 2022, 5:04pm UTC](https://community.weweb.io/t/add-to-cart-button/866 "2022-07-25T17:04:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [July 25, 2022, 6:30pm UTC](https://community.weweb.io/t/add-to-cart-button/866/2 "2022-07-25T18:30:30Z")

</div>

A very basic example:

- create a variable “simple-cart” of type Object default to `{}`  

- create a list of cards binding the items to a list of products (you need a unique id for every product). In the example I am using an array of data directly in the formula but this should be from a collection or another data source.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/f/fc94935a98834347b8c6c2460f623c607a24b762.png)  

- to add a product create a workflow with two actions:

- to remove a product create a workflow with two actions:

- to get the total amount of a product in a cart:  

result showing the value of the variable:  
 ![chrome_mZE5Hezawy](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/d1e04dcb6b84079868fd5e6518eed70a3346d819.gif)

---

_[View the full topic](https://community.weweb.io/t/add-to-cart-button/866)._
