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.
// 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");
}
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.
var totalShipping = baseShippingCost + Item.AdditionalShippingCharge;
Array of attributes with Key, Value, IsRequired, Prompt, PriceAdjustment, etc.
// 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;
Array of batch tiers (same as PricingTiers but for batch tier table)
if (Item.IsBatch && Item.BatchTiers.length > 0) {
var batchTier = HelperMethods.FindTier(Item.NumberOfRecords, Item.BatchTiers);
if (batchTier) {
debug("Batch tier price: $" + batchTier.Price);
}
}
Indicates whether the item has a job behind it (an editor or upload job) whose properties, such as the weight, can be set by the script. False when there is no job yet, for example when the price is calculated on the product page before the customer has started a job. CanSetWeight is the older name for the same check.
if (Item.CanSetJobProperties) {
debug("Pricing job " + Item.JobId);
}
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.
if (Item.CanSetWeight && Item.Weight > 5000) {
debug("Heavy item detected - weight: " + Item.Weight + "g");
// Apply heavy item surcharge
return Item.Price + 10.00;
}
Index of this item in the other order item array (-1 if not in array)
if (Item.CartItemIndex >= 0) {
debug("This is cart item #" + (Item.CartItemIndex + 1));
}
Alias of OtherOrderItems
// 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;
}
Array of category names that this product belongs to. Categories are used for product organization, filtering, and category-specific pricing rules.
if (HelperMethods.Contains(Item.Categories, "Premium")) {
return Item.Price * 1.1; // 10% premium markup
}
Array of customer role system names
// Check for wholesale pricing
if (HelperMethods.Contains(Item.CustomerRoles, "Wholesale")) {
debug("Wholesale customer detected");
return Item.Price * 0.70; // 30% wholesale discount
} else if (HelperMethods.Contains(Item.CustomerRoles, "VIP")) {
return Item.Price * 0.90; // 10% VIP discount
}
Department name of user
// 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
}
The cost code of the customer's department, if the customer belongs to one. Empty when the customer has no department, or the department has no cost code set. Useful for cost-centre-based pricing rules or for tagging the calculated price.
// Apply cost-centre-specific pricing
if (Item.DepartmentCostCode == "CC-100") {
debug("Cost centre CC-100 order");
return Item.Price * 0.90; // 10% discount for cost centre CC-100
}
Value of the currently used discount code
// 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
}
User email
// Apply corporate discount for company emails
if (/@mycompany\.com$/i.test(Item.Email)) {
debug("Corporate customer: " + Item.Email);
return Item.Price * 0.85; // 15% corporate discount
}
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.
var finalTotal = Item.FinalPrice;
console("Final price for " + Item.Quantity + " units: $" + finalTotal);
The height of the item in the configured dimension unit (typically inches or centimeters). This value is used for packaging calculations and dimensional pricing.
// Check if item is oversized
if (Item.Height > 48) {
debug("Oversized item - adding handling fee");
return Item.Price + 25.00;
}
Whether this is a batch job
if (Item.IsBatch) {
debug("Processing batch job with " + Item.NumberOfRecords + " records");
var batchSetupFee = 25.00;
return Item.Price + batchSetupFee;
}
Whether this item is in the other order item array
if (Item.IsInOtherOrderItems) {
debug("Item is part of multi-item order");
// Consider other items for bundle pricing
}
True when the script is run to build the product page tier price table (ScriptContext is "LandingPageWithTierPrices"). In this mode, call setTierPrice for each tier quantity.
if (Item.IsTierPriceMode) {
for (var i = 0; i < Item.PricingTiers.length; i++) {
setTierPrice(Item.PricingTiers[i].Quantity, Item.PricingTiers[i].Price * 0.9);
}
}
Whether this is a version of a job
if (Item.IsVersion) {
debug("This item is a version of an existing job");
// Use version-specific pricing logic
}
The ID of the job behind the item, or null when there is no job yet (see CanSetJobProperties).
if (Item.JobId) {
console("Job: " + Item.JobId);
}
The length of the item in the configured dimension unit (typically inches or centimeters). This value is used for packaging calculations and dimensional pricing.
// Calculate volume for shipping
var volume = Item.Width * Item.Height * Item.Length;
var volumetricWeight = volume / 5000; // Standard divisor
debug("Volumetric weight: " + volumetricWeight);
Number of pages (-1 if not valid)
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;
}
Number of records (-1 if not valid)
if (Item.NumberOfRecords > 0) {
var perRecordCost = 0.05;
var recordCost = Item.NumberOfRecords * perRecordCost;
debug("Batch has " + Item.NumberOfRecords + " records");
return Item.Price + recordCost;
}
Number of versions
if (Item.NumberOfVersions > 1) {
debug("Multi-version job with " + Item.NumberOfVersions + " versions");
// Apply version discount
return Item.Price * 0.95; // 5% multi-version discount
}
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.
if (Item.OldPrice > Item.Price) {
var discount = Item.OldPrice - Item.Price;
return "Save $" + discount.toFixed(2);
}
Index of this item in the other order item array (0 if not in array)
// Apply setup fee only to first item
if (Item.OrderItemIndex == 0) {
debug("First item - adding setup fee");
return Item.Price + 15.00;
}
Array of other order items using the same custom pricing script
// 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);
The pack quantity, calculated as the order quantity divided by the product variant's OrderPackQuantity. This represents how many packs are being ordered.
var packPrice = Item.Price * Item.PackQuantity;
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.
var basePrice = Item.Price;
var adjustedPrice = basePrice * 1.2; // 20% markup
Price per record (-1 if not valid)
if (Item.PricePerRecord > 0 && Item.NumberOfRecords > 0) {
var recordTotal = Item.PricePerRecord * Item.NumberOfRecords;
debug("Record pricing: " + Item.NumberOfRecords + " x $" + Item.PricePerRecord);
return recordTotal;
}
Array of pricing tiers with Price, Quantity, and CustomerRole
// 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;
}
The product cost, representing the actual cost to produce or acquire the product. This value is used for margin calculations and profit analysis.
var margin = Item.Price - Item.ProductCost;
var marginPercentage = (margin / Item.Price) * 100;
The name of the product group the product belongs to, or null when it is not in a group.
if (Item.ProductGroupName == "Business Cards") {
debug("Business card pricing applies");
}
The numeric ID of the product. Useful when one script is shared by several products and needs product-specific rules.
if (Item.ProductId == 1234) {
return Item.Price * Item.Quantity * 0.9; // 10% off this product only
}
The name of the product as displayed to customers. This is the human-readable product name used in the user interface and order confirmations.
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
}
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.
var tier = HelperMethods.FindTier(Item.Quantity, Item.PricingTiers);
The quantity selector mode for this product. This determines how quantity selection is handled in the user interface and affects pricing calculations.
switch (Item.QuantitySelectorMode) {
case 1: // Individual units
return Item.Price * Item.Quantity;
case 2: // Packs
return Item.Price * Item.PackQuantity;
}
The mode the script is running in: "Product", "CheckoutAttribute" or "LandingPageWithTierPrices".
if (Item.ScriptContext == "CheckoutAttribute") {
debug("Pricing a checkout attribute");
}
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.
// Apply SKU-specific pricing rules
if (Item.Sku && Item.Sku.indexOf("PREMIUM-") == 0) {
debug("Premium product: " + Item.Sku);
return Item.Price * 1.10; // 10% premium markup
}
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.
var finalPrice = Item.SpecialPrice || Item.Price;
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.
var now = new Date();
if (Item.SpecialPriceEndDate && now <= Item.SpecialPriceEndDate) {
return Item.SpecialPrice;
}
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.
var now = new Date();
if (Item.SpecialPriceStartDate && now >= Item.SpecialPriceStartDate) {
return Item.SpecialPrice;
}
Array of the product's specification attributes, each with a Key, Value and DefaultValue. Value is localized to the customer's language; DefaultValue is the untranslated value, which is the safer one to compare against in scripts.
for (var i = 0; i < Item.Specifications.length; i++) {
var spec = Item.Specifications[i];
if (spec.Key == "Paper Weight" && spec.DefaultValue == "350gsm") {
return Item.Price * Item.Quantity + 15.00; // heavy stock surcharge
}
}
Array of tag names associated with this product. Tags are used for product classification, search optimization, and tag-based pricing rules.
if (HelperMethods.Contains(Item.Tags, "Featured")) {
return Item.Price * 1.05; // 5% featured product markup
}
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.
var unitPrice = Item.UnitPrice;
var totalForQuantity = unitPrice * Item.Quantity;
Array of versions with JobId, CustomName, and Quantity
// 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);
}
}
Sum of all quantities of all versions
// 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;
}
}
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.
// 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);
The width of the item in the configured dimension unit (typically inches or centimeters). This value is used for packaging calculations and dimensional pricing.
// 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);
Serialize a value to an indented JSON string.
Returns "null" for null, and a JSON object with an error property if serialization fails.
Known issue: inside pricing scripts this currently fails for every value and returns
{"error": "Serialization failed: ... ReflectionPermission ..."}, because the script sandbox
blocks the serializer. Until that is fixed, log values with LogObject
or string concatenation instead.
The value to serialize
JSON text
// Works today: log the fields yourself
for (var i = 0; i < Item.Specifications.length; i++) {
console(Item.Specifications[i].Key + " = " + Item.Specifications[i].Value);
}
Get file information for the file uploaded to a file upload attribute. Returns null when the attribute has no uploaded file.
For text and CSV files, readContent counts the lines into NumberOfRecords;
the file's lines are not returned. Use the three-argument overload to get them.
ID of the file upload attribute, as a string (String(attr.Id))
Whether to read text and CSV files to count their records
FileInfo object, or null
for (var i = 0; i < Item.Attributes.length; i++) {
var attr = Item.Attributes[i];
if (attr.Type == "FileUpload") {
var file = Item.getFileInfo(String(attr.Id), false);
if (file && file.NumberOfPages > 0) {
debug(attr.Prompt + ": " + file.NumberOfPages + " pages");
}
}
}
Get file information for the file uploaded to a file upload attribute, optionally including the content of text and CSV files. Returns null when the attribute has no uploaded file.
With readContent and getTextFileContent both true, text and CSV files also fill
Content (the lines) and, for CSV, CsvContent (rows by columns).
ID of the file upload attribute, as a string (String(attr.Id))
Whether to read text and CSV files
Whether to return the file's lines as well as the record count
FileInfo object, or null
var file = Item.getFileInfo(String(attr.Id), true, true);
if (file && file.CsvContent) {
debug("Uploaded list has " + (file.CsvContent.length - 1) + " addresses");
}
Get file information for a specific configurable file from Global Data
Name of the file
FileInfo object
// 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];
}
}
// 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
Name of the CSV file
2D array representing CSV content, or null if file doesn't exist
// 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");
}
// 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
}
Look up rows in a CSV file from Global Data by the values of one or more columns. The file is indexed by the given columns on first use and the index is cached, so repeated lookups in large price tables stay fast.
The result's first row is the header row; the matching rows follow it. All values are strings. Returns null when the file does not exist, or when the two arrays are empty or differ in length.
Name of the CSV file in Global Data
Header names of the columns to match on; order matters
Values to match, in the same order as indexedColumnNames
Header row followed by the matching rows, or null
var rows = Item.getRowsFromLookup("prices.csv", ["Material", "Size"],
[Item.getAttributeValue("Material"), Item.getAttributeValue("Size")]);
if (rows && rows.length > 1) {
// Values are platform strings, so find the column with == rather than indexOf
var priceColumn = 0;
for (var c = 0; c < rows[0].length; c++) {
if (rows[0][c] == "Price") {
priceColumn = c;
}
}
return parseFloat(rows[1][priceColumn]) * Item.Quantity;
}
error("No price found for this combination");
Generated using TypeDoc
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.