# Dynamic calculation of the price of a product by using mini-programmes

Some products are not subject to simple pricing rules. Their price depends on many parameters, which only the trader understands. Thanks to the openness of the IdoSell service, you can order or place a JavaScript-written piece of software in the product, which will calculate its price according to any rules. This module will also prove useful when you need to define parameters, relationships between them - sometimes the easiest way to do it is in the form of a micro program. In this way, you will define which combinations, e.g. describing a roller blind, machine or pipe, a customer can choose and how the price will depend on their length. The price can be defined in such a way that a pipe with a certain length costs much more in the chrome-plated option (because a chrome-plating machine takes a certain size as standard and then you have to make it with another process). Or you can define a mathematical function that will determine the price of a pipe that will grow with its length, with an exponential function. The possibilities of application are endless.

## Why mini-programs?

In advanced applications such as pricing custom-made products, the price does not depend on the sum of the components. For example, you cannot get the price of e.g. a mast by multiplying only the length given in centimetres by the price in centimetres. In life, the mast can be up to a certain length. Within a certain length range it is cut from a standard "pipe" for example. In the further length range from the longer and then very high masts are made from scratch to order, but the longer the mast, the thicker it will be, so the price will not increase linearly. There are thousands of such valuations in the world of personalized products. So far the owners of such shops have been doomed to open source software, in which they could obtain such action by modifying its code. However, thanks to the possibility of using in the IdoSell service mini-programs called by us formulas for calculating prices in JavaScript, you can write a piece of software that will calculate the price and then upload it into a special field in the editing of a product.

## Example of using the formula to calculate the price in JavaScript in the IdoSell store mask

A product card with a choice of parameters that affect the final price calculated using the JS formula.

"Carted product at a price generated by the JS formula.

Details of an order containing a product whose price has been generated using the JS formula.

## Security against fraudsters

Of course you could ask, what's the big deal? After all, I can write a program in JavaScript in any program and add it to the product card e.g. in the description field. Sure, but this way, a hacker or a user who knows the basics of JavaScript could modify the value of variables in the page code of his browser and then "inject" the price he considers appropriate (e.g. 150 GBP instead of 300 GBP) and order a more expensive product for that.

As the IdoSell service is created for professional and automated shops, our solution is very safe. When you decide to add a product to the shopping cart, a program written in JavaScript is run with selected parameters of a product card on the server side, and in this way the price is calculated, which is processed in the cart. Therefore, the modification of the product value by the user shall not give him anything, as it shall not cheat the system.

All works on the creation of the configurator are settled in the mode time & material