PRO

Formatting Prices Using #ecommerce_price

Numbers can be formatted as prices in WS Form using the #ecommerce_price variable.

#ecommerce_price can be used on your form (e.g. in the default value of field) and also in actions (e.g. the Send Email action).

Syntax

The syntax of the #ecommerce_price variable is as follows:

#ecommerce_price(number)

The parameters are as follows:

ParameterExampleDescription
number#field(123) or 12345.6789The input number.

Currency Settings

#ecommerce_price automatically formats the number using your e-commerce currency settings. This includes the currency symbol, currency position, number of decimals, decimal separator, and thousand separator.

Currency settings are configured in Global Settings under the E-Commerce tab. If WooCommerce is installed, WS Form uses the WooCommerce currency settings.

Examples

These examples use a field with ID 123 that has a value of 123456.789. The output shown assumes US Dollar currency settings ($ on the left, 2 decimal places, period decimal separator, comma thousand separator).

ExampleOutput
#ecommerce_price(#field(123))$123,456.79
#ecommerce_price(1234.5)$1,234.50
#ecommerce_price(#calc(#field(123) * 2))$246,913.58

If you change your currency settings, the same variable will output a price that matches those settings. You do not need to pass decimal or separator parameters.

For number formatting without a currency symbol, use #number_format.

Dynamically Updating with #text

If you want a price to change dynamically if the number parameter changes, you can wrap the variable in #text. For example:

#text(#ecommerce_price(#field(123)))

This would output the value of field ID 123 as a price, keeping it updated if field ID 123 changes.