Calculating total price from order lines

0
Hi all, I'm building a restaurant takeout app and I'm having issues with calculating the total price from order lines that are present in the shopping cart. I built a microflow which retrieves the list of order lines and adds them up, then it returns a decimal.   My domain model consists of an entity 'OrderLine’ which holds the amount of a certain product and the line price as attributes, and another entity 'Order’ which has the 'TotalPrice’ attribute. I want to show the 'TotalPrice' attribute on the same page that displays the order lines, but I can't get that part to work. It seems like I can't use that attribute on the page.   Any thoughts on how I can make this work? This is the microflow:   This is my domain model:    This is the page on which I want to display the total price:     And finally, this is the error:
asked
4 answers
0

The error that you get here is an inconsistency error. This type of error exists if a page expects a parameter or if this page is referred through with a button or microflow etc. 
To fix this you would have to create an object of the ‘Order’ type on the page.
This can be done trough a microflow/nanoflow where you create the object and pass it as a return value. 
You can use this as a datasource for the dataview. 

 

answered
0

You're trying to add a menu item that leads to the page ShoppingCart_Overview. However, the shopping cart page doesn't know which order you want to show on that page, because you're not passing “Order” to the page.

 

Instead of adding a menu item with “Show a Page”, change the “On click” to “Microflow”. In the microflow:

  • Retrieve the correct order for this customer
  • Do a “show page” action where you pass this order to the page.

This should solve your error!

answered
0

Hi Pieter,

 

You are getting the error as the page is expecting the object of “Order” passed into it when you click to show it, this is due to [Order, page parameter] data view that is at the bottom of the page. Something like the following may work for you.

This will show all of the orders and all of the items within that order.

 

Hope this helps.

 

Thanks,

 

Chris

answered
0

Thanks everyone for the swift response! I found what I was looking for with your help.

answered