Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

All pricing scripts can be written with the JavaScript Programming Language.

You don’t need to be a programmer to understand how to build a pricing script.
Using and modifying the example scripts is actually quite simple.

There are 3 places in the software where pricing scripts can be used:

For all scrips the same principles apply:

  • Preset Variables are available to be used for pricing

  • Both Mathematical Expressions and JavaScript Functions can be used in the Pricing Script

  • The Last Line of the script must output the final price

General Examples to Understand Pricing Concepts

These are general examples to explain the basic concepts of algorithmic pricing.
The respective pages (linked above) have more specific and realistic examples of pricing scripts.

Constant Pricing

If a fee or part should be priced the same for all users and for all orders, that can be input a single number into the script. Examples might be a fixed processing cost, a handling fee or a fixed price for internal prototyping in your company.

20.50  // default prototyping fee

Using Variables and Mathematical expressions

Each new variable must be defined with the keyword let. Then the variables can be used with normal arithmetic functions.

let a = 10 + 20;   // addition
let b = 30 - 5;    // subtraction
let c = 2 * 5;     // multiplication
let d = 10 / 2;    // division
let e = 10 ** 2    // exponentiation
a + b + c + d + e; // last line contains final price


Pre-defined Variables from Model Analysis

Depending on the algorithm type (Materials, Post-Processing, Order Fees), there are different sets of variables available within the platform. Those variables will fill in use value pulled from the uploaded and analyzed 3D model.

let cost1 = model.volume * 0.0002; // model.volume in cubic mm
let cost2 = model.area * 0.02;     // model.area in square mm
let price = cost1 + cost2;
price;                             // last line contains final price

Providing Conditions & Discounts

In order to offer competitive pricing, especially for larger orders or particular customer groups, the if/else functionality can adjust the price based on specific conditions. Additional support variables are available under User-based Pricing.

let price = model.volume * 0.0002;  // model.volume in cubic mm

// Add a 10% Discount when ordering more then 10 items
if(item.quantity > 10) {
    price = price * 0.90;
}

// Provide a 5% Discount for Users with a @3yourmind Address
else if(user.email && user.email.endsWith('@3yourmind.com')) {
    price = price * 0.95;
}

// 90$ Discount if price is above 1500
else if(price > 1500) {
    price = price - 90;
}

price; // last line contains final price
  • No labels