## Description

**Product Price by Formula for WooCommerce** plugin lets you set formula for automatic WooCommerce product price calculation.

*Plugin settings are accessible via “WooCommerce > Settings > Product Price by Formula”.*

### Bulk Settings

- Enable for all products
- Enables price calculation by formula for all products.
- Default:
`no`

- Default:
- Disable for product IDs
- If you have checked “Enable for all products” option, you can optionally add product exceptions here (i.e. price calculation by formula will be disabled for these products). Set it as comma separated list of product IDs.
- Default:
*None*

- Default:
- Disable for product category IDs
- If you have checked “Enable for all products” option, you can optionally add product category exceptions here (i.e. price calculation by formula will be disabled for these product categories). Set it as comma separated list of product category IDs.
- Default:
*None*

- Default:
- Use same formula
- Enables same formula for all products. Possible values: No; Yes (with individual params); Yes (with same params).
- Default:
`No`

- Default:

### General Settings

- Disable for empty price
- Disables price by formula for products with empty price.
- Default:
`yes`

- Default:

### Admin Settings

- Add dashboard widget
- Adds default settings admin dashboard widget.
- Default:
`no`

- Default:
- Products list columns
- Adds columns to the admin products list. Possible values: Formula; Params; Price.
- Default:
*None*

- Default:

### Advanced Settings

- Shortcodes prefix
- Optional prefix for all plugin’s shortcodes. E.g.: if set to
`my_prefix_`

, will transform`[math_round]`

to`[my_prefix_math_round]`

.- Default:
*None*

- Default:
- Price filters priority
- Priority for WooCommerce price filters. Set to zero to use the default priority.
- Default:
`0`

- Default:
- Plugin URLs
- By default plugin applies price calculations on frontend only. If you need to apply it on other URLs, enter URLs here. One URL per line. E.g.:
`/wp-admin/edit.php?post_type=product`

- Default:
*None*

- Default:
- Price changes
- Try enabling this checkbox, if you are having compatibility issues with other plugins.
- Default:
`no`

- Default:

### Default Formula Settings

You can set default settings here. All settings can later be changed on individual product’s edit page (in **Product Price by Formula** meta box).

In **formula** use `x`

variable for product’s base price. For example: `x+p1*p2`

. Please note that you can **not** use `x`

or `pN`

**inside other params**.

In **formula and/or params** use can also use shortcodes.

Please note that if you are using **caching plugins** and dynamic product pricing (e.g.: price changing with product stock (`[product_stock]`

) or by customer’s location (`[if_customer_location]`

)), then caching needs to be disabled for products pages. If you want to keep caching enabled, you will need to cache product pages for each condition: for example for `[if_customer_location]`

you can set *Default customer location* option to *Geolocate (with page caching support)* in *WooCommerce > Settings > General*.

- Formula
- Price formula.
- Default:
*None*

- Default:
- Number of parameters
- Save settings after you change this number – new settings fields will appear.
- Default:
`1`

- Default:
- pN: Value
- Parameter value.
- Default:
*None*

- Default:
- pN: Admin note (optional)
- Optional parameter admin note.
- Default:
*None*

- Default:

### Shortcodes

`[math_round]`

– Rounding shortcode. Number of decimals can be set with `precision`

attribute.

#### Example

[math_round precision="1"][if_customer_location country="US,CA"]x*1.10[/if_customer_location][if_customer_location not_country="US,CA"]x*1.20[/if_customer_location][/math_round]

`[math_ceil]`

– Rounding up (ceil).

#### Example

[math_ceil]x*[product_weight][/math_ceil]

`[math_floor]`

– Rounding down (floor).

#### Example

[math_floor]x*[product_length][/math_floor]

`[math_min]`

– Min value.

#### Example

[math_min value1="x*p1" value2="x*p2"]

`[math_max]`

– Max value.

#### Example

[math_max value1="x*p1" value2="{product_total_sales}"]

`[product_meta]`

– Retrieves any meta for the product. Meta key is set by required `key`

attribute.

#### Example

[product_meta key="_weight"]

`[product_total_sales]`

– Retrieves product’s total sales number.

#### Example

[product_total_sales]

`[product_stock]`

– Retrieves product’s stock.

#### Example

[product_stock]

`[product_weight]`

– Retrieves product’s weight.

#### Example

[product_weight]

`[product_length]`

– Retrieves product’s length.

#### Example

[product_length]

`[product_width]`

– Retrieves product’s width.

#### Example

[product_width]

`[product_height]`

– Retrieves product’s height.

#### Example

[product_height]

`[product_id]`

– Product’s ID.

#### Example

[if_value value="{product_id}" compare_operator="in" compare_to_value="100,101,102"]x*4.9[/if_value][if_value value="{product_id}" compare_operator="not_in" compare_to_value="100,101,102"]x*5.5[/if_value]

`[product_attr]`

– Retrieves product’s attribute. Attribute is set by required `attribute`

attribute.

#### Example

[product_attr attribute="size"]

`[if_customer_location]`

– Price by customer’s location (by IP).

#### Example

[if_customer_location country="US,CA"]x*1.10[/if_customer_location][if_customer_location not_country="US,CA"]x*1.20[/if_customer_location]

`[if_time]`

– Price by current time.

#### Example

[if_time from="00:00:00" to="11:59:59"]x*1.10[/if_time][if_time from="12:00:00" to="23:59:59"]x*1.20[/if_time]

`[if_date]`

– Price by current date.

#### Example

[if_date from="2018-09-15 00:00:00" to="2018-10-15 23:59:59"]x*1.10[/if_date][if_date from="2018-10-16 00:00:00" to="2019-09-14 23:59:59"]x*1.20[/if_date]

`[if_user_role]`

– Price by customer’s user role.

#### Example

[if_user_role role="guest,administrator"]x*1.10[/if_user_role][if_user_role not_role="guest,administrator"]x*1.20[/if_user_role]

`[if_user_id]`

– Price by customer’s user ID.

#### Examples

[if_user_id id="1,5"]x*1.10[/if_user_id][if_user_id not_id="1,5"]x*1.20[/if_user_id]

x[if_user_id id="0"]*2[/if_user_id]

`[if_product_category]`

– Price by product’s category.

#### Example

x[if_product_category slug="cat1,cat2"]*1.10[/if_product_category][if_product_category not_slug="cat1,cat2"]*1.20[/if_product_category]

`[if_product_tag]`

– Price by product’s tag.

#### Example

x[if_product_tag slug="tag1,tag2"]*1.10[/if_product_tag][if_product_tag not_slug="tag1,tag2"]*1.20[/if_product_tag]

`[if_product_taxonomy]`

– Price by product’s taxonomy (any).

#### Example

x[if_product_taxonomy taxonomy="product_cat" slug="cat1,cat2"]*1.10[/if_product_taxonomy][if_product_taxonomy taxonomy="product_cat" not_slug="cat1,cat2"]*1.20[/if_product_taxonomy]

`[if_value]`

– Compares any two values. Required attributes: `value`

, `compare_operator`

and `compare_to_value`

. Possible compare operators are: `equal`

, `not_equal`

, `less`

, `less_or_equal`

, `greater`

, `greater_or_equal`

, `in`

, `not_in`

, `between`

, `not_between`

. There is also `inclusive`

attribute for `between`

, `not_between`

compare operators.

#### Example

x[if_value value="{product_meta key='_weight'}" compare_operator="less" compare_to_value="1.5"]*4.9[/if_value][if_value value="{product_meta key='_weight'}" compare_operator="greater_or_equal" compare_to_value="1.5"]*5.5[/if_value]

`[if_product_id]`

– Price by product’s ID.

#### Example

[if_product_id compare_operator="in" compare_to_value="100,101,102"]x*4.9[/if_product_id][if_product_id compare_operator="not_in" compare_to_value="100,101,102"]x*5.5[/if_product_id]

`[if_product_meta]`

– Price by product’s meta.

#### Example

[if_product_meta key="_weight" compare_operator="less" compare_to_value="100"]p1[/if_product_meta][if_product_meta key="_weight" compare_operator="greater_or_equal" compare_to_value="100"]p2[/if_product_meta]

`[if_regular_price]`

– Apply formula to regular product price.

#### Example

x[if_regular_price]*2[/if_regular_price][if_sale_price]/2[/if_sale_price]

`[if_sale_price]`

– Apply formula to sale product price.

#### Example

x[if_regular_price]*2[/if_regular_price][if_sale_price]/2[/if_sale_price]

`[option]`

– Site option.

#### Example

x+[option name="my_option_name" default="1"]

### Usage Examples

#### Example 1

Let’s say product’s standard (i.e. original) price is $50 and its stock is 15 pcs. If you set **Formula** to `x+p1*p2`

, **Number of parameters** to `2`

, **p1** to `1.5`

and **p2** to `[product_stock]`

, then final price will be `50 + 1.5 * 15 = 72.5`

, i.e. $72.50.

#### Example 2

Let’s say you need to use `[if_value]`

shortcode. While you could enter `value`

directly, usually you will need to retrieve it from another shortcode or meta field, e.g. product weight. As placing `[`

, `]`

and `"`

in shortcode’s attributes is not allowed in WordPress, you will need to replace it with `{`

, `}`

and `'`

accordingly, e.g.:

x[if_value value="{product_meta key='_weight'}" compare_operator="less" compare_to_value="1.5"]*4.9[/if_value][if_value value="{product_meta key='_weight'}" compare_operator="greater_or_equal" compare_to_value="1.5"]*5.5[/if_value]

In the example above: product’s original price (`x`

) will be multiplied by `4.9`

in case if product weight (`{product_meta key='_weight'}`

) is less than `1.5`

. And it will be multiplied by `5.5`

if product weight is greater or equal to `1.5`

.

Moreover you can add shortcodes inside `[if_value]`

shortcode’s content, e.g.:

[if_value value="{product_meta key='_weight'}" compare_operator="less" compare_to_value="1.5"][product_meta key="_length"]*4.9[/if_value][if_value value="{product_meta key='_weight'}" compare_operator="greater_or_equal" compare_to_value="1.5"][product_meta key="_length"]*5.5[/if_value]

#### Example 3

Using `[product_attr]`

shortcode in `[if_value]`

shortcode:

x[if_value value="{product_attr attribute='color'}" compare_operator="equal" compare_to_value="Gray"]*1.25[/if_value]

In this example all products with “Gray” color attribute will have a 25% price markup.

5out of 5jon–I think your product is the right one for me and think I should buy it but can’t seem to get it working.

We sell roller blinds so product price depends on the width and drop of the blind. This is entered by the customer.

I have already added these field (i.e. width and drop) using the “extra product option plugin” and have the fields named as width and drop on the front end.

What I can’t seem to do is link these fields to the formula in your plugin.

I have called p1 [width] and p2 [drop] and have just for a test tried the formula p1*x. I was hoping it would pick up the value of the width entered by the customer but I probably have this completely wrong.

I get the message Error in $p1*$x formula: Undefined Value [width].

So the actual width is entered by the customer on the product page and is not a fixed unit. Is this something that your plugin can work with. In other words can it respond to user input on the [product page and if so would you please tell me how so I can test this before I buy it.

5out of 5Ramiro Iriñiz–Hi this is a PRE BUY question.

We are using DIVI THEME with WOOCOMMERCE and we would like to know if this plugin let us make this kind of formulas.

– PRODUCT PRICE / 10

– PRODUCT PRICE with 10% discount.

How should we put this Result Variables in the PRODUCT PAGE?

With SHORTCODE?

Thanks

5out of 5Slavcho Georgiev–I ask support if the plugin have very specific functionality that I need.

I got an answer that it can be added to next release and 24 hours later that next release was available to download!!!

Thank you!!!

5out of 5masterez–The plugin functions like it should and the support in great!

5out of 5Ajay Maharjan–hello!

Before purchasing the API I would like to know if you can calculate with below example

Product value = round(Price * Product Weight * 1.15,0)

*Price: Need to change every day for bulk products ( around 200 items)

*Product weight: Will input by a user at the time of product entry.

* 1.15: just a number

Tom Anbinder–Hi,

Sorry for a late reply.

Yes, that is possible. Please set this as

(Default) Formula:or more generally:

Hope that helps.

5out of 5djmfxp–hi

i want buy and use “Product Price by Formula for WooCommerce”

but i want know some details

i want use a unique single formula for all products(all product use a one formula)

but any products use own paramaters for universal formula.

can i do with this plugin?

Tom Anbinder–Yes, that is possible by selecting “Yes (with individual params)” option in “Use same formula” dropdown in plugin’s “General” settings.