Calculations
The eCart Object can be configured to calculate values based on column contents of your cart, or custom calculations written in server-side code. Calculations refer not only to numeric values, but the concatenation of text from columns in the cart.
The results of these calculations can then be displayed as custom columns within the shopping cart display.
For example, three commonly used calculations are automatically available upon creation of the object:
The results of these calculations can then be displayed as custom columns within the shopping cart display.
For example, three commonly used calculations are automatically available upon creation of the object:
- Total Weight: for a line item in the shopping cart, this is the weight of the item multiplied by the number of that item in the cart.
- Total Price: for a line item in the shopping cart, this is the price of the item multiplied by the number of that item in the cart.
- Full Details: this is a string built up for each line item that contains the name of the item, its ID, and its quantity. It is typically used for posting a basic transaction description from a checkout form.
To create a custom calculation:
- Click the Add button to add a blank calculation to the eCart Object.
- In the Name field, specify a unique name for the calculation that will identify its result within the Display Manager. Be sure that the name is not the same as any existing column or calculation configured in the eCart Object.
- From the Output Type list, select one of the six available data types to format the calculation result. Available options are Number, Text, Weight, Integer, Date and Currency.
- In the Calculations field, specify the calculation by one of the following methods:
- Numerical column calculations: you may add, subtract, multiply and divide values available in specified columns of the cart using these corresponding operators: +,-,*,/. Columns are specified within a calculation by placing the column name in brackets - all lower case.
e.g. TotalPrice = [Price] * [Quantity]
English equivalent:
Total Price for a specific quantity of an item in the cart
is equal to
the price of an item in the cart (retrieved from the cart Price column)
multiplied by ( the quantity for that item
the quantity of the item in the cart (retrieved from the cart Quantity column)
- Text calculations: the text from multiple columns can be displayed within a single column by concatenating the information. Columns are specified within a calculation by placing the column name in brackets - all lower case. Literal text to be displayed must be encapsulated in quotation marks.
e.g. a user sells T-Shirts and has a column of Color defined for the item. To display the item and the color within a single column requires the following calculation:
Display Text: VNeck: Blue
Calculation: [Name]+": "+[Color] - Server-side calculations: Advanced users can write server-side code within the calculation field to write custom calculations based on the global variables available in the site.
- Numerical column calculations: you may add, subtract, multiply and divide values available in specified columns of the cart using these corresponding operators: +,-,*,/. Columns are specified within a calculation by placing the column name in brackets - all lower case.
- Select a different calculation in the display pane to apply your changes.
- Proceed with additional configuration or click OK to complete the eCart Object configuration.
To update an existing calculation:
- Select an existing calculation from the list of available calculations. The configuration details for the selected calculation populate the console above the calculations listing.
- Make any edits or changes to the calculation.
- Click the Update button to apply the changes within the console. Changes will populate the listing for the selected calculation.
- Click OK to apply the changes to the eCart object.