The main item object available in pricing scripts. Represents the product variant being priced and provides access to all product information, attributes, pricing data, and methods for file handling and attribute management.

This object is the primary interface for accessing product data and performing pricing calculations in pricing scripts.

Hierarchy

  • Item

Properties

ActualSku: string

The actual SKU based on the current attribute combination. If no attributes are selected, this will be the same as the product SKU. This value reflects the specific configuration of the product being priced.

Example

// Log the configured SKU for debugging
debug("Base SKU: " + Item.Sku);
debug("Configured SKU: " + Item.ActualSku);
if (Item.ActualSku !== Item.Sku) {
debug("Product has attribute variations");
}
AdditionalShippingCharge: number

Additional shipping charge for this specific product variant. This value is added to the base shipping cost and represents any extra shipping fees specific to this item.

Example

var totalShipping = baseShippingCost + Item.AdditionalShippingCharge;
Attributes: Attribute[]

Array of attributes with Key, Value, IsRequired, Prompt, PriceAdjustment, etc.

Example

// Loop through all attributes and apply price adjustments
var totalAdjustment = 0;
for (var i = 0; i < Item.Attributes.length; i++) {
var attr = Item.Attributes[i];
debug("Attribute: " + attr.Key + " = " + attr.Value);
totalAdjustment += attr.PriceAdjustment || 0;
}
return Item.Price + totalAdjustment;
BatchTiers: Tier[]

Array of batch tiers (same as PricingTiers but for batch tier table)

Example

if (Item.IsBatch && Item.BatchTiers.length > 0) {
var batchTier = HelperMethods.FindTier(Item.NumberOfRecords, Item.BatchTiers);
if (batchTier) {
debug("Batch tier price: $" + batchTier.Price);
}
}
CanSetWeight: boolean

Indicates whether the weight can be set or modified for this item. Some products may have fixed weights that cannot be changed, while others allow weight adjustments based on attributes or custom settings.

Example

if (Item.CanSetWeight && Item.Weight > 5000) {
debug("Heavy item detected - weight: " + Item.Weight + "g");
// Apply heavy item surcharge
return Item.Price + 10.00;
}
CartItemIndex: number

Index of this item in the other order item array (-1 if not in array)

Example

if (Item.CartItemIndex >= 0) {
debug("This is cart item #" + (Item.CartItemIndex + 1));
}
CartItems: Item[]

Alias of OtherOrderItems

Example

// Apply cart-wide discount if total exceeds threshold
var cartTotal = 0;
for (var i = 0; i < Item.CartItems.length; i++) {
cartTotal += Item.CartItems[i].Price * Item.CartItems[i].Quantity;
}
if (cartTotal > 500) {
debug("Cart total $" + cartTotal + " - applying 10% discount");
return Item.Price * 0.90;
}
Categories: string[]

Array of category names that this product belongs to. Categories are used for product organization, filtering, and category-specific pricing rules.

Example

if (Item.Categories.includes("Premium")) {
return Item.Price * 1.1; // 10% premium markup
}
CustomerRoles: string[]

Array of customer role system names

Example

// Check for wholesale pricing
if (Item.CustomerRoles.indexOf("Wholesale") >= 0) {
debug("Wholesale customer detected");
return Item.Price * 0.70; // 30% wholesale discount
} else if (Item.CustomerRoles.indexOf("VIP") >= 0) {
return Item.Price * 0.90; // 10% VIP discount
}
Department: string

Department name of user

Example

// Apply department-specific pricing
if (Item.Department === "Marketing") {
debug("Marketing department order");
return Item.Price * 0.80; // 20% marketing discount
} else if (Item.Department === "Sales") {
return Item.Price * 0.75; // 25% sales discount
}
DiscountCode: string

Value of the currently used discount code

Example

// Apply special discount for specific codes
if (Item.DiscountCode === "SUMMER20") {
debug("Summer sale discount applied");
return Item.Price * 0.80; // 20% off
} else if (Item.DiscountCode === "VIP50") {
return Item.Price * 0.50; // 50% off
}
Email: string

User email

Example

// Apply corporate discount for company emails
if (Item.Email.endsWith("@mycompany.com")) {
debug("Corporate customer: " + Item.Email);
return Item.Price * 0.85; // 15% corporate discount
}
FinalPrice: number

The final calculated price for this item, including all discounts and adjustments. If the pricing script is attached to a product, this will be the product variant price multiplied by the quantity. If the pricing script is attached to a checkout attribute, it represents the total price for the entire quantity of this item after all pricing rules have been applied.

Example

var finalTotal = Item.FinalPrice;
console("Final price for " + Item.Quantity + " units: $" + finalTotal);
Height: number

The height of the item in the configured dimension unit (typically inches or centimeters). This value is used for packaging calculations and dimensional pricing.

Example

// Check if item is oversized
if (Item.Height > 48) {
debug("Oversized item - adding handling fee");
return Item.Price + 25.00;
}
IsBatch: boolean

Whether this is a batch job

Example

if (Item.IsBatch) {
debug("Processing batch job with " + Item.NumberOfRecords + " records");
var batchSetupFee = 25.00;
return Item.Price + batchSetupFee;
}
IsInOtherOrderItems: boolean

Whether this item is in the other order item array

Example

if (Item.IsInOtherOrderItems) {
debug("Item is part of multi-item order");
// Consider other items for bundle pricing
}
IsVersion: boolean

Whether this is a version of a job

Example

if (Item.IsVersion) {
debug("This item is a version of an existing job");
// Use version-specific pricing logic
}
Length: number

The length of the item in the configured dimension unit (typically inches or centimeters). This value is used for packaging calculations and dimensional pricing.

Example

// Calculate volume for shipping
var volume = Item.Width * Item.Height * Item.Length;
var volumetricWeight = volume / 5000; // Standard divisor
debug("Volumetric weight: " + volumetricWeight);
NumberOfPages: number

Number of pages (-1 if not valid)

Example

if (Item.NumberOfPages > 0) {
var perPageCost = 0.10;
var pageCost = Item.NumberOfPages * perPageCost;
debug("Document has " + Item.NumberOfPages + " pages, adding $" + pageCost);
return Item.Price + pageCost;
}
NumberOfRecords: number

Number of records (-1 if not valid)

Example

if (Item.NumberOfRecords > 0) {
var perRecordCost = 0.05;
var recordCost = Item.NumberOfRecords * perRecordCost;
debug("Batch has " + Item.NumberOfRecords + " records");
return Item.Price + recordCost;
}
NumberOfVersions: number

Number of versions

Example

if (Item.NumberOfVersions > 1) {
debug("Multi-version job with " + Item.NumberOfVersions + " versions");
// Apply version discount
return Item.Price * 0.95; // 5% multi-version discount
}
OldPrice: number

The old price from the product variant, typically used for displaying price comparisons or discounts. This value represents the previous price before any recent price changes.

Example

if (Item.OldPrice > Item.Price) {
var discount = Item.OldPrice - Item.Price;
return "Save $" + discount.toFixed(2);
}
OrderItemIndex: number

Index of this item in the other order item array (0 if not in array)

Example

// Apply setup fee only to first item
if (Item.OrderItemIndex === 0) {
debug("First item - adding setup fee");
return Item.Price + 15.00;
}
OtherOrderItems: Item[]

Array of other order items using the same custom pricing script

Example

// Calculate total quantity across all cart items for volume discount
var totalQty = Item.Quantity;
for (var i = 0; i < Item.OtherOrderItems.length; i++) {
totalQty += Item.OtherOrderItems[i].Quantity;
}
debug("Total quantity in cart: " + totalQty);
PackQuantity: number

The pack quantity, calculated as the order quantity divided by the product variant's OrderPackQuantity. This represents how many packs are being ordered.

Example

var packPrice = Item.Price * Item.PackQuantity;
Price: number

The standard product variant price in the base currency. This is the base price before any attribute adjustments, tier pricing, or special pricing is applied.

Example

var basePrice = Item.Price;
var adjustedPrice = basePrice * 1.2; // 20% markup
PricePerRecord: number

Price per record (-1 if not valid)

Example

if (Item.PricePerRecord > 0 && Item.NumberOfRecords > 0) {
var recordTotal = Item.PricePerRecord * Item.NumberOfRecords;
debug("Record pricing: " + Item.NumberOfRecords + " x $" + Item.PricePerRecord);
return recordTotal;
}
PricingTiers: Tier[]

Array of pricing tiers with Price, Quantity, and CustomerRole

Example

// Find the best tier for the current quantity
var tier = HelperMethods.FindTier(Item.Quantity, Item.PricingTiers, Item.CustomerRoles);
if (tier) {
debug("Using tier: " + tier.Quantity + " @ $" + tier.Price);
return tier.Price * Item.Quantity;
}
ProductCost: number

The product cost, representing the actual cost to produce or acquire the product. This value is used for margin calculations and profit analysis.

Example

var margin = Item.Price - Item.ProductCost;
var marginPercentage = (margin / Item.Price) * 100;
ProductName: string

The name of the product as displayed to customers. This is the human-readable product name used in the user interface and order confirmations.

Example

debug("Processing order for: " + Item.ProductName);
// Check for special product names
if (Item.ProductName.indexOf("Rush") >= 0) {
debug("Rush order product detected");
return Item.Price * 1.50; // 50% rush fee
}
Quantity: number

The order quantity for this item. This represents how many units of this product variant are being ordered. Used for quantity-based pricing and tier calculations.

Example

var tier = HelperMethods.FindTier(Item.Quantity, Item.PricingTiers);
QuantitySelectorMode: number

The quantity selector mode for this product. This determines how quantity selection is handled in the user interface and affects pricing calculations.

Example

switch (Item.QuantitySelectorMode) {
case 1: // Individual units
return Item.Price * Item.Quantity;
case 2: // Packs
return Item.Price * Item.PackQuantity;
}
Sku: string

The Stock Keeping Unit (SKU) of the product variant. This is the unique identifier for the product variant and is used for inventory management and order processing.

Example

// Apply SKU-specific pricing rules
if (Item.Sku.startsWith("PREMIUM-")) {
debug("Premium product: " + Item.Sku);
return Item.Price * 1.10; // 10% premium markup
}
SpecialPrice: number

The special price for the product variant, if applicable. This value is null if no special pricing is currently active. Special pricing typically overrides the standard price for promotional periods.

Example

var finalPrice = Item.SpecialPrice || Item.Price;
SpecialPriceEndDate: Date

The end date for special pricing, if applicable. This value is null if no special pricing is currently active. Used to determine if special pricing should be applied based on current date.

Example

var now = new Date();
if (Item.SpecialPriceEndDate && now <= Item.SpecialPriceEndDate) {
return Item.SpecialPrice;
}
SpecialPriceStartDate: Date

The start date for special pricing, if applicable. This value is null if no special pricing is currently active. Used to determine if special pricing should be applied based on current date.

Example

var now = new Date();
if (Item.SpecialPriceStartDate && now >= Item.SpecialPriceStartDate) {
return Item.SpecialPrice;
}
Tags: string[]

Array of tag names associated with this product. Tags are used for product classification, search optimization, and tag-based pricing rules.

Example

if (Item.Tags.includes("Featured")) {
return Item.Price * 1.05; // 5% featured product markup
}
UnitPrice: number

The calculated unit price for this item. If the pricing script is attached to a product, this will be the product variant price. If the pricing script is attached to a checkout attribute, this will be the price per individual unit including discounts and all the adjustments.

Example

var unitPrice = Item.UnitPrice;
var totalForQuantity = unitPrice * Item.Quantity;
Versions: ItemVersion[]

Array of versions with JobId, CustomName, and Quantity

Example

// Calculate pricing across all versions
if (Item.Versions.length > 0) {
debug("Job has " + Item.Versions.length + " versions");
for (var i = 0; i < Item.Versions.length; i++) {
var ver = Item.Versions[i];
debug("Version: " + ver.CustomName + ", Qty: " + ver.Quantity);
}
}
VersionsSumQuantity: number

Sum of all quantities of all versions

Example

// Use total version quantity for tier pricing
if (Item.VersionsSumQuantity > 0) {
var tier = HelperMethods.FindTier(Item.VersionsSumQuantity, Item.PricingTiers);
if (tier) {
debug("Using combined version quantity: " + Item.VersionsSumQuantity);
return tier.Price;
}
}
Weight: number

The weight of the item in the configured weight unit (typically grams or ounces). This value is used for shipping calculations and weight-based pricing.

Example

// Calculate shipping cost based on weight
var weightInKg = Item.Weight / 1000;
var shippingRate = 2.50; // $2.50 per kg
var shippingCost = weightInKg * shippingRate;
debug("Item weight: " + Item.Weight + "g, Shipping: $" + shippingCost);
Width: number

The width of the item in the configured dimension unit (typically inches or centimeters). This value is used for packaging calculations and dimensional pricing.

Example

// Calculate area-based pricing
var area = Item.Width * Item.Height;
var pricePerSquareUnit = 0.05;
var areaCost = area * pricePerSquareUnit;
debug("Area: " + area + " sq units, Cost: $" + areaCost);

Methods

  • Shortcut method to retrieve an attribute value by name

    Parameters

    • attribute: string

      Name of the attribute

    Returns string

    Attribute value

  • Get file information for attached files

    Parameters

    • attributeId: string

      ID of the attribute

    • readContent: boolean

      Whether to read file content

    Returns FileInfo

    FileInfo object

  • Get file information for a specific configurable file from Global Data

    Parameters

    • filename: string

      Name of the file

    Returns FileInfo

    FileInfo object

    Example

    // Method 1: Using getGlobalFileContent (current approach)
    var fileInfo = Item.getGlobalFileContent("test.csv");
    if (fileInfo && fileInfo.CsvContent) {
    console("CSV file loaded successfully with " + fileInfo.CsvContent.length + " rows");
    var headers = fileInfo.CsvContent[0]; // First row contains headers

    // Process CSV data from FileInfo object
    for (var i = 1; i < fileInfo.CsvContent.length; i++) {
    var row = fileInfo.CsvContent[i];
    // Access data by column index
    var firstColumn = row[0];
    var secondColumn = row[1];
    }
    }

    Example

    // For non-CSV files, access raw content
    var textFile = Item.getGlobalFileContent("config.txt");
    if (textFile && textFile.Content) {
    console("File content: " + textFile.Content);
    }
  • Get CSV file content as a 2D array from Global Data

    Parameters

    • filename: string

      Name of the CSV file

    Returns string[][]

    2D array representing CSV content, or null if file doesn't exist

    Example

    // Basic CSV loading and processing
    var csvData = Item.getGlobalFileCsvContent("test.csv");
    if (csvData) {
    console("CSV data loaded directly as array with " + csvData.length + " rows");

    // Extract column names from first row
    function getColumnNames(csvTable) {
    if (csvTable && csvTable.length > 0) {
    return csvTable[0]; // Returns array of column names
    }
    return [];
    }

    var columnNames = getColumnNames(csvData);
    console("Available columns: " + columnNames.join(", "));

    // Process data rows (skip header row)
    for (var i = 1; i < csvData.length; i++) {
    var row = csvData[i];
    // Access data by column index
    var firstColumn = row[0];
    var secondColumn = row[1];
    }
    } else {
    console("CSV file not found or empty");
    }

    Example

    // Method 2: Using getGlobalFileCsvContent (preferred for CSV files)
    var csvData = Item.getGlobalFileCsvContent("test.csv");
    if (csvData) {
    console("Direct CSV access with " + csvData.length + " rows");
    // csvData is already a 2D array, no need to access .CsvContent property
    }
  • Set the attribute value permanently to the given value

    Parameters

    • attribute: string

      Name of the attribute

    • value: string

      Value to set

    Returns void

Generated using TypeDoc