Simplio3D

Pricing & CPQ

Configure and calculate prices with base prices, lookup tables, variables, and formulas.

List Pricing Blocks

const blocks = await client.getPricingBlocks('proj_123');
blocks.forEach(b => {
  console.log(b.name, b.type, b.basePrice || b.variableKey);
});

Create Base Price

const block = await client.createPricingBlock('proj_123', {
  type: 'base-price',
  name: 'Base Price',
  basePrice: 499.99,
  baseCurrency: 'USD'
});

Create Variable

const widthVar = await client.createPricingBlock('proj_123', {
  type: 'variable',
  name: 'Width',
  variableKey: 'width',
  variableDefaultValue: 120,
  variableMin: 80,
  variableMax: 200,
  variableStep: 10,
  variableUnit: 'cm'
});

Update Price Table

await client.updatePricingBlock('proj_123', 'pb_3', {
  tableRows: [
    { id: 'r1', cells: { col_1: 'oak' }, priceAdjustment: 0 },
    { id: 'r2', cells: { col_1: 'walnut' }, priceAdjustment: 120 },
    { id: 'r3', cells: { col_1: 'marble' }, priceAdjustment: 399 }
  ]
});

Calculate Price

const price = await client.calculatePrice('proj_123', {
  selections: {
    dropdownSelections: { 'blk_wood': 'walnut' },
    selectMaterialSelections: {},
    checkboxSelections: { 'blk_accessories': ['cup-holder'] },
    toggleSwitchSelections: { 'blk_armrests': 'with' },
    carouselSelections: {}
  },
  variables: { width: 160, quantity: 2 }
});

console.log('Base:', price.basePrice);
console.log('Adjustments:', price.adjustments);
console.log('Total:', price.totalPrice, price.currency);
console.log('Formatted:', price.formatted);  // "$1,223.99"
console.log('Tax:', price.formattedTax);      // "$204.00"
console.log('Subtotal:', price.formattedSubtotal); // "$1,019.99"
// Tax, formatting, and currency are applied based on Project Settings > Price

Continue reading