Add Cart Page

I want an idea for creating adding the products to cart Page for the shopping cart app ,suggest me the widgets and microflows ???
1 answers



You can start with creating domain model something like this.


With this domain model a customer can have multiple orders. An order can have multiple orderlines, and an orderline always refers to 1 product. So you can have an Order which has an orderline for Product “Spoon” with a quantity of 5. And an orderline for Product “Fork” with a quantity of 10.

The “Add to cart” button would first have to check if there's already an orderline created for this particular order and this particular Product. You can do this by retrieving the first OrderLine which has an association to the current order and which has an association to selected product. You should probably have these available as parameters already if your page has the Order as it's context object and the list of products in your listview.

If there isn't an OrderLine found, it needs to create it. Be sure to set both associations when creating the object.
Then you need to update the orderline object with the correct quantity of items (in this case a +1 for adding an item) and commit the orderline object.


You can find Shopping cart scenarios in the Mendix academy learnings.