How to Add products to the cart en culculate the final price?

my domain model/   and here is the microflow where i add products to the cart , ths mircoflows triggers from a add to cart button, can you culculate the price in the same microflow or should u make another seperate one for this? can you explain me in detail what kind of activities do i need because i am facing this form days, stil failed to get the total price,   tthis microflow adds the products to the cart but not culculating the final price, i am doing something wrong, can you detect and correct?
1 answers

You are creating a new cart item, and then retrieving a cart item list from the database that I assume does not include a reference to your current cart, since you don't create your cart until afterwards. How I would make the flow:


  • Do a find-or-create flow of a cart object with an association to the customer. This way, if the cart already exists, you retrieve that one instead of creating a new one.
  • Calculate the cartitem price by multiplying the price of the product with the number of items the customer selected.
  • For the product the customer selected, create a cartitem that is associated with the cart. This puts the cartitem "in" the cart. Also add the cartitem price.
  • Over association, retrieve all cartitems from the cart
  • Take the sum of all cart items and save it in your cart object as the total.