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:
  • 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.
By default, these calculations are available as display columns when creating a shopping cart display.

To create a custom calculation:

  1. Click the Add button to add a blank calculation to the eCart Object.
  2. 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.
  3. 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.
  4. 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.
    Note: To assist in building your calculation string, you may use the Add to formula feature to select from a list of available cart columns or default calculations and place the string corresponding to that value in the calculation field.
  5. Select a different calculation in the display pane to apply your changes.
  6. Proceed with additional configuration or click OK to complete the eCart Object configuration.

To update an existing calculation:

  1. Select an existing calculation from the list of available calculations. The configuration details for the selected calculation populate the console above the calculations listing.
  2. Make any edits or changes to the calculation.
  3. Click the Update button to apply the changes within the console. Changes will populate the listing for the selected calculation.
  4. Click OK to apply the changes to the eCart object.

Calculations and Merchandising

For events and conditions used in creating merchandising rules, calculation results are available as conditions in the cart in the same manner that columns are.