Add a List of Order Items
If we're going to sell something, well need to add items to the order. To do this, I'll add a new screen called "Order Items".
Canvas has a special screen layout called a List. When you add a screen with a list layout, Canvas automatically creates a series of screens that build a list of items. The mobile user will see one screen with list of items he has collected, and they can click the "Add" button to add a new item to the list.
The Canvas mobile user will then fill out a second screen with the details for the list item. When that screen is completed, they will loop back to the first screen and see the new item in his list. This would normally be a complex interaction to program, but Canvas makes it simple and easy to just get it done.
All we have to do now is add fields to the item detail screen. Let's put in a product name and quantity.
We need to charge the customer for each item, so we'll need a price field. Price is obviously a monetary value, so we'll need to use the appropriate field from the Palette. Let's use a decimal field since it will let the user enter dollars and cents. We'll put a dollar sign in the label to indicate that we are using U.S. dollars as the currency. To make the app international, you would instead add another field to denote the currency.
To get a subtotal for the order, we're going to need to calculate the amount for each line item. The calculation field solves this problem for us.
Calculation fields can perform basic arithmetic functions on any fields in the current screen or on constants you specify. Let's calculate amount as quantity times price.
