Function that only one product can be added to the shopping cart

Hello,

I wanted to ask how I can add just one product from a product list to the shopping cart in Adalo, and how the add button disappears if the product is already in the shopping cart. Currently, I don’t know how to set the button’s visibility and filters so that the button is only displayed if no order item has been created for this product. Does anyone have any ideas? :slight_smile:

Best Regards

Christian

Hi @chrisW,

Welcome to the forum!

You can use “Counts” approach to manage this visibility. Let’s assume you have Products, Carts and Cart Items:

  • create a relationship between Products and Cart Items, so that each Cart Item can belong only to one Product. Also you need a relationship Carts - Cart Items (one cart can have many items).
  • when you add an item to the cart, you do it with the action Create Cart Item, and you set the relationship to Product and to Cart at this time
  • then: on the Product list entry (e.g. Add button), you add a visibility condition, so that Current Cart → Cart Items → Count, where Cart Item → Product → ID is equal to Current Product → ID, is equal to 0.

Please see the screenshot (collection names are different):

Best,
Victor

Hello Victor,

Great, thank you very much. It worked! :slightly_smiling_face: :+1:

Best Regards

Christian

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.