Cart and favorites

A list in the app memory: private to each visitor — a table cannot do this.

The “Add to cart” button in the shop template, and its list action.
The “Add to cart” button in the shop template, and its list action.

A cart is a table with the “Everyone writes their own” permission. An ordinary table is read the same by everyone and written by you; here it is the other way round — the visitor creates the row and only they see it. That is why a cart survives a reload: close the messenger, come back a day later, and it is still there.

  1. Create a cart table with title, price and image columns and set “Records from the app: Everyone writes their own”. Do not type rows into it — the visitor creates them.
  2. On the “Add to cart” button use Add a record: table cart, and under “what to store” put columns and substitutions — title = {{item.title}}, price = {{item.price}}. No form required. For several equal products, use Quantity with list cart and the selected product’s title and price. It saves one row per unit in the same private table. Turn off One row per visitor for the cart.
  3. On the cart screen put a List from a table with cart as its source. Inside the card use {{item.title}} and a Remove a record button with {{item}} as “which record”.
  4. The sum is the Total component: which table to add up (cart) and which field (price). The badge over the icon is {{cart.count}}.
  5. After checkout use Clear my records with the cart table. It removes only the records of the person who checked out: other people’s carts, and anything you typed into the table yourself, stay put.

Read next