This article explains how you use javascript constants in the product configurator backend, for example in formulas for price determinations.

In our example we want to determine an extra charge with the help of a formula. 

We have generated a characteristics named "Befestigung" (attachment) that includes four selectable variants A, B, C and D with the values 0,1,2,3 (marked with a red frame), as shown in the picture below. 

Furthermore, for our example we generate the characteristic "Anzahl" (number) with the data type selection with the values 1 to 10. 

In the configurator frontend the customer is now able to select the variant of attachment and the number of attachments. 

Finally, we create the last characteristic "Aufpreis_Befestigung" (extra charge attachment) with the data type "formula". Here, the extra charge should be determined in dependency of the selected number of attachments.

Under "calculation" you enter the formula:   

In the configurator backend constants are generated via javascript with the symbol $ and the respective ID of the characteristic. $befestigung and $anzahl are constants and work as space holders for the value the customer selects in the frontend. The symbol * stands for multiplication. At the end of every javascript row you have to insert a semicolon (;) in order to complete the command.
 
Example: The customer selects the attachment C with the associated value 2 and the number 6 with the associated value 6 (see above). The values are multiplied (*) in the formula and thus result in an extra charge of 12. 

If you want to directly include the extra charge into the price determination in the fronend, go to the characteristic with the formula and insert value 0=0; price=1 below season price.

If you do not want to integrate the extra charge, do not enter anything. 

Please give us a feedback! Does this article help you? If not, please do not hesitate to contact us personally via chat (blue chat button).

Did this answer your question?