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);

Generated using TypeDoc