wm.b2b.cxml.shared.data:computeTotal
WmcXML12. Computes the total of a list of items.
Each item is represented by a record containing a field for the price and quantity of the item. The total is computed by multiplying price and quantity of each item and then summed together.
Input Parameters
lineItemList | List of records, each representing an item. |
priceFieldName | The field name for price in the item record. If the field name is nested inside one or more sub-records, specify a relative path to that field, using a / (a slash) to separate each sub-record name. |
quantityFieldName | The field name for quantity in the item record. If the field name is nested inside one or more sub-records, specify a relative path to that field, using a / (a slash) to separate each sub-record name. |
previousTotal | Optional. If set, the amount that should be added to the computed total for the item list. |
Output Parameters
total | Total amount of items. |
allItemsComputed | If true, all items were used to compute the total. |
itemsNotComputed | If allItemsComputed is false, itemsNotComputed will be the list of items that were not computed as part of the total. |
Usage Notes
priceFieldName and quantityFieldName can refer to a string field in any sub-record inside the item record. The string field and the sub-record(s) must be scalar (they cannot be lists).
For a string field nested in a sub-record, you specify a relative path from the item record to the string field.
For example, assume each item is represented by a record that:
Contains a string field quantity.
Contains a record field price. The price sub-record contains a string field amount.
Then, the total can be computed by setting:
quantityFieldName to quantity
priceFieldName to price/amount