Info |
---|
This page contains a listing of available variables for adjusting pricing at the Order Level. |
In contrast to scripts for materials and post-processing, Order Level Pricing Scripts are meant to be applied based on the selections of the customer while ordering. That is why these variables are accessible for each material and post-processing method.
As Order Level Pricing Scripts are applied to a whole order, they are not added to a material pricing script. Instead, place them in Settings → Agile ERP Settings → Order Pricing → Additional Order Fees.
Available Order Level Variables
Variable | Description |
---|---|
| Line volume for the first line. |
| Line support volume for the first line. |
All other | See |
| Line unit price for the first line. |
| Line quantity |
| Line name |
| Material name of the line item |
| 3D printing technology of the line item |
| Post processing title, price (net) and color for the line item |
| Line density for the material |
| Boolean, if true if shipping type is Pick Up Location |
User Based Pricing |
Note: If Manual Pricing is enabled and triggered, the resulting Request will have a total request value of ‘null’. Therefore, if using the lines[0].price
variable, it is necessary to allow for this null condition in the pricing script to avoid a script error.
Examples
Shipping Fee based on Weight
Calculates the weight of all models in the basket and charges €10 / kg as an additional shipping fee.
Code Block | ||
---|---|---|
| ||
let mass = 0; let rate = 10; let total_volume = 0; let total_quantity = 1; const countryCodes = ['DK', 'DNK', 'NO', 'NOR', 'FI', 'FIN', 'SE', 'SWE'] let userCode = user.country_code; if ((userCode) && (countryCodes.includes(userCode))) { for (let line of lines) { total_quantity = line.quantity; total_volume = (line.model.volume + line.support.volume) * total_quantity mass += total_volume * line.product.density_min / 1000000; } } let additional_cost = rate * mass; additional_cost; |
Discount based on pickup location selected
Code Block | ||
---|---|---|
| ||
let discount;
if (pick_up){
discount = 100;
} else {
discount = 1;
}
-discount; |
Discount based on Material
In this example, a discount is applied if the total volume / area of the total order of all items in a specific material exceeds a threshold.
Code Block | ||
---|---|---|
| ||
// Discount Based on total volume / area // Change this to the material const material = "PA12"; // leave the following lines untouched let material_subtotal = 0; let material_volume = 0; let material_area = 0; let discount = 0; for (let line of lines) { if (line.product.title == material) { material_volume += line.model.volume; material_area += line.model.area; material_subtotal += parseFloat(line.price); } } // Adjust the following variables for you needs if (material_volume > 10000 && material_area > 1000) { discount = 0.05 * material_subtotal; } else if (material_volume > 20000 && material_area > 2000) { discount = 0.10 * material_subtotal; } // Last line contains the negative fee = discount. -discount; |
Additional Fee for Changing Materials
Checks if there are models with different materials but the same technology. If yes, we will charging charge $25 for each material switch on a machine.
Code Block | ||
---|---|---|
| ||
const all_technologies = lines.map((line) => line.product.technology); let all_technologies_grouped = new Set(all_technologies); let n = 0; let fee = 25; for (let technology of all_technologies_grouped) { let v = []; for (let line of lines) { if(line.product.technology == technology) { v.push(line.product.title); } } let new_v = new Set(v); n += new_v.size - 1; } n * fee; |
Minimum Order Fee for Materials & Post-Processing
This script takes care that the printing and/or post-processing will cost at least a certain amount. It will only work from version 4.2 on.
Code Block | ||
---|---|---|
| ||
// Minimum Order Priceses
// Adjust the titles and values here.
// All items from the order in this material combined
// must at least cost this much.
// If a line contains a material that is not in this list
// it is ignored by this script (also the Post-Processing of it)
const materialsMinPrices = {
"PA12": 69,
"PA 2210 FR": 69,
"Accura Xtreme": 69,
};
// Adjust the titles and values here.
// All items from the order in this post processing combined
// must at least cost this much.
// If coloring is used, each color counts seperately.
const ppMinPrices = {
"Coloring": 5,
"Polishing": 5,
"Sandblasting": 5,
};
// Don't modify the following lines
let materialsUsed = {};
let ppsUsed = {};
for (let line of lines) {
if (!line.price) continue; // line is manually priced
let materialTitle = line.product.title;
if(materialTitle in materialsMinPrices) {
if (!(materialTitle in materialsUsed)) {
materialsUsed[materialTitle] = parseFloat(materialsMinPrices[materialTitle]);
}
materialsUsed[materialTitle] -= parseFloat(line.price);
for (let postProcessing of line.post_processings) {
let ppTitleColor = postProcessing.color ? materialTitle + postProcessing.title + postProcessing.color : postProcessing.title;
if (!ppTitleColor || !postProcessing.price) { continue; }
if (!(ppTitleColor in ppsUsed)) {
ppsUsed[ppTitleColor] = parseFloat(ppMinPrices[postProcessing.title]);
}
ppsUsed[ppTitleColor] -= parseFloat(postProcessing.price);
if(materialTitle in materialsMinPrices) {
materialsUsed[materialTitle] += parseFloat(postProcessing.price);
}
}
}
}
let fee = 0;
for (let [material, value] of Object.entries(materialsUsed)) {
if (value > 0) {
fee += value;
}
}
for (let [pp, value] of Object.entries(ppsUsed)) {
if (value > 0) {
fee += value;
}
}
fee; |