Custom scripts

The module allows you to load a custom script in each product page.
Additionally, you can load a global script which applies to all products with the module enabled.
Path of the global script:

Path of the custom script:

You can use these scripts to extend the module functionality in an easy way.
Each field gets a function that is called when the field value is changed by the customer, here’s an example:
Supposing the field name is “width”, the function name is then “dp_width”.
The “dp_” prefix stands for “Dynamic Product” and aims to prevent any conflict with existing functions.

Detecting calculation results

To detect the calculation rest, you need to subscribe to the dp_calc store like this

Open your browser console to see the structure of the data that is returned by the calculator

This is useful when you want to read the result prices

Here’s an example output of the data variable

Saving the the customization

If you would like to save the customization programmatically, you can use this function

The add_to_cart parameter is either true or false

 

Fields validation

To trigger the fields validation, you can use the validateFieds function

Articles

Was this article helpful to you? Yes 3 No