Declarations files

The declarations files are similar to the allocations files but their result is used in JS (in the custom scripts)

You can use them to make PHP variables available in JS. For example, declare the current customer group to JS.

Be careful, don’t reveal sensitive information as any other visitor can see these variables.

The path of the declarations folder is /modules/dynamicproduct/declarations  or /dynamicproduct/declarations if you have version 2.3 or above
The file should be named productXX.php where XX is replaced by the desired product ID.
As an example for product #7, you can create a file “product7.php” and add your code to declare your variables.

Additionally, you can add a global declaration file with the name “products.php” in the “declarations” folder which will affect all products.



So you need to define an array called declarations in order for the module to detect these variables

Was this article helpful to you? Yes No