CSV parsing and stringifying utilities for data-driven pricing Provides comprehensive CSV handling capabilities for working with external data files, configuration data, and bulk pricing information
// Parse CSV file content
var csvContent = HelperMethods.CSV.parse(fileContent);
// Generate CSV output
var outputData = [["Product", "Price"], ["Item A", "10.99"]];
var csvOutput = HelperMethods.CSV.stringify(outputData);
Check if arrays contain specific values for conditional logic Utility function for checking array membership in conditional pricing logic
Array to check for the specified value
Value to search for in the array
Whether the value is found in the array
if (HelperMethods.Contains(Item.CustomerRoles, "VIP")) {
// Apply VIP pricing logic
}
Find appropriate pricing tier based on quantity and customer roles Searches through tier arrays to find the best matching tier for the given quantity and customer roles, supporting both regular pricing tiers and batch tiers
The quantity which you would like the price to be worked out based on
An array of object literals [{Quantity: n, Price: n, CustomerRole?: string}]
Optional
roles: string[]Array of string that contains customer roles, falls back to Customer.Roles if not supplied
Tier object or null if no matching tier found
var tiers = [{Quantity: 1, Price: 5}, {Quantity: 50, Price: 17}, {Quantity: 250, Price: 60}];
var tier = HelperMethods.FindTier(100, tiers, ["SuperAdmin", "Admin"]);
// Returns the tier with Quantity: 50, Price: 17
Get attribute price adjustments including tier-based adjustments Calculates the total price adjustment for all selected attributes, taking into account tier-based pricing adjustments that can vary based on quantity or customer roles
The quantity which you would like the price to be worked out based on
Optional
roles: string[]Array of string that contains customer roles, falls back to Customer.Roles if not supplied
Total price adjustment including all attribute and tier adjustments
var attributeAdjustment = HelperMethods.GetAttributePriceAdjustment(43, ["SuperAdmin", "Admin"]);
// Returns the total price adjustment for quantity 43 with specified customer roles
Interpolate prices between tier boundaries for smooth pricing transitions Calculates a price that falls between tier boundaries based on the specified quantity, providing smooth pricing curves rather than step-based pricing
The quantity which you would like the price to be worked out based on
An array of object literals [{Quantity: n, Price: n}] for interpolation
Interpolated price based on quantity position within the specified tiers
var interpolationTiers = [
{Quantity: 1, Price: 5}, {Quantity: 50, Price: 17},
{Quantity: 250, Price: 60}, {Quantity: 500, Price: 100},
{Quantity: 1000, Price: 200}
];
var tierPrice = HelperMethods.InterpolatePrice(Item.Quantity, interpolationTiers);
// Returns interpolated price based on Item.Quantity position within tiers
Type checking utility for robust script development Determines if an item is a plain object (not null, not array, not primitive)
Item to check if it's an object
Whether the item is an object
if (HelperMethods.IsObject(config)) {
// Process configuration object
}
Log object properties for debugging complex pricing scenarios Outputs all properties of an object to the console for debugging purposes, useful for examining complex data structures during script development
Object to log all properties from
HelperMethods.LogObject(Item);
// Logs all Item properties to console for debugging
Deep merge objects with conflict resolution for combining pricing data Merges source object properties into target object, handling nested objects and providing a way to combine configuration data from multiple sources
Target object to merge properties into
Source object to merge properties from
var baseConfig = {markup: 20, shipping: 5};
var overrideConfig = {markup: 25};
HelperMethods.MergeObject(baseConfig, overrideConfig);
// baseConfig now has {markup: 25, shipping: 5}
Generated using TypeDoc
Helper methods available in pricing scripts for common calculations and data manipulation These utilities extend the capabilities of pricing scripts and help create more flexible and maintainable pricing logic.