The session object available in pricing scripts. Represents session-level data and provides access to customer information and shopping cart items that are available during the current session.

This object provides session-wide context for pricing calculations that may need to consider multiple items or customer session data.

Hierarchy

  • Session

Properties

CartItems: Item[]

Array of shopping cart items in the current session. Contains all active shopping cart items for the current customer session. Each item provides full access to product information, attributes, and pricing data.

Example

console("Session has " + Session.CartItems.length + " items");
for (var i = 0; i < Session.CartItems.length; i++) {
var item = Session.CartItems[i];
console("Item: " + item.ProductName + " - $" + item.Price);
}
CustomerRoles: string[]

Array of customer role system names for the current session. Contains all roles assigned to the customer in the current session. Used for role-based pricing and access control.

Example

console("Customer roles: " + Session.CustomerRoles.join(", "));
if (Session.CustomerRoles.includes("VIP")) {
console("VIP customer - apply special pricing");
}
Department: string

Department name of the customer for the current session. Represents the department or organizational unit the customer belongs to. Used for department-specific pricing and business logic.

Example

console("Customer department: " + Session.Department);
if (Session.Department === "Education") {
console("Educational department - apply academic discount");
}
DepartmentCostCode: string

Cost code of the customer's department for the current session. Empty when the customer has no department, or the department has no cost code set. Used for cost-centre-based session pricing and business logic.

Example

console("Customer department cost code: " + Session.DepartmentCostCode);
if (Session.DepartmentCostCode === "CC-100") {
console("Cost centre CC-100 - apply centre-specific pricing");
}
DiscountCode: string

Value of the discount code currently applied in the session. Reflects the discount coupon code entered by the customer, if any. Used to apply code-specific pricing or promotions at the session level.

Example

if (Session.DiscountCode === "SUMMER20") {
console("Summer discount code applied in session");
}
Email: string

Customer email address for the current session. Provides access to the customer's email address associated with the session.

Example

console("Session customer email: " + Session.Email);
if (Session.Email.endsWith(".edu")) {
console("Educational customer detected");
}
OtherOrderItems: Item[]

Alias for CartItems - array of other order items in the session. Provides the same functionality as CartItems for backward compatibility.

Example

var totalSessionValue = 0;
for (var i = 0; i < Session.OtherOrderItems.length; i++) {
totalSessionValue += Session.OtherOrderItems[i].Price * Session.OtherOrderItems[i].Quantity;
}
console("Total session cart value: $" + totalSessionValue);

Methods

  • Get the current value of a checkout attribute for the session customer. The attribute is matched by name, ignoring case. For attributes with predefined values (drop-down, radio buttons, checkboxes) the value names are returned, comma-separated when several are selected. Returns an empty string when the attribute does not exist or has no value.

    Parameters

    • attribute: string

      Name of the checkout attribute

    Returns string

    The stored value, or an empty string

    Example

    var deliveryType = Session.getCheckoutAttributeValue("Delivery Type");
    if (deliveryType === "Express") {
    console("Express delivery selected - apply surcharge");
    }
  • Set a checkout attribute value for the session customer. The value is saved on the customer and carried into the order, the same as if the customer had entered it at checkout. The attribute is matched by name, ignoring case.

    The value must suit the attribute type:

    • Drop-down, radio buttons, checkboxes: the name of one of the attribute's predefined values. For checkboxes the value is added to the existing selection.
    • Date picker: a date, preferably in ISO format (yyyy-MM-dd).
    • Number: a number using . as the decimal separator.
    • Informational attributes cannot hold a value.

    If the attribute does not exist or the value is invalid, an error message is reported and nothing is saved. Setting the value it already holds does nothing. The call is ignored while tier prices are being calculated.

    Parameters

    • attribute: string

      Name of the checkout attribute

    • value: string

      Value to set

    Returns void

    Example

    if (Session.CustomerRoles.includes("Wholesale")) {
    Session.setCheckoutAttributeValue("Delivery Type", "Pallet");
    }

    Example

    Session.setCheckoutAttributeValue("Required By", "2026-12-24");
    

Generated using TypeDoc