Hello @gregorr64,
The shortcode [CP_CALCULATED_FIELDS_VAR] is used to generate global javascript variables with parameters that were passed to the page (by get or post) or session variables. In your case the variable myParam would be generated only if the page is being visited passing the parameter myParam by post.
There are two possible solutions to your project.
– If you are inserting the form’s shortcode into the page’s content, and you know the value of the custom field, simply pass it as another attribute in the form’s shortcode, it would be converted into a javascript variable with global scope that can be used in the equations as usual. In this hypothetical example:
[CP_CALCULATED_FIELDS id="1" myparam="456"]
Note that I’m passing the parameters in lowercase, WordPress always converts the names of attributes in the shortcodes to lowercase.
Now you can implement in the form an equation similar to:
fieldname1*myparam
– Reading the custom field with the “DS” fields (The “DS” fields, is a set of fields distributed with the Developer and Platinum versions of the plugin, whose values are read from external data-sources, like a MySQL database or a CSV file).
Assuming that myParam was stored as a metadata associated to the post:
* Pass the post id as reference into the form’s shortcode: [CP_CALCULATED_FIELDS id="1" post_id="123"]
* Insert a “Line Text DS” field in the form (or the DS field that corresponds to the datatype)
* And enter as the query associated to the DS field:
SELECT meta_value as value FROM {wpdb.postmeta} WHERE meta_key='myParam' AND post_id=<%post_id%>
The DS field will contains the value of the custom field myParam corresponding to the post_id passed as attribute in the shortcode.
Best regards.