*98*

WooCommerce is a powerful and feature-rich WordPress plugin. But despite the fact it’s got many features, there is always something missing for custom ecommerce businesses.

The problem with “*all-you-can-do plugins*” is the same as “*all-in-one WordPress themes*“: the more custom functionalities a piece of software has, the worse its performance gets.

Therefore, there is no need to pack every imaginable functionality into WooCommerce as it is easily expandable with other plugins.

For example, one particular feature is not available in WooCommerce out of the box: the possibility to **use math formulas to calculate product prices**.

This functionality is crucial for specific industries such as digital printing, custom-sized furniture, curtains, tiles, rollers and so on.

Curious to know how this can be implemented?

## The idea and purpose of flexible price calculation

Quite often, businesses need to use some variables for a proper and accurate price calculation. It is relevant for **products with measurements** like width or height. Typically these are advertisement banners and other printing products, rollers and shutters etc.

Another use case would be when a **product involves customization**, e.g. ingredients or services, so a customer is allowed to choose add-ons. A perfect example would be a food ordering form, like pizza or cakes. Usually, the price for such products is based on quantity and type of ingredients added.

Other examples: personalized medals, gift wrappings, custom cut glasses/mirrors or even online game user rank upgrades!

## There is a handy plugin for that

Uni CPO WordPress plugin lets you use math formulas for product prices – any formula! Whatever you put inside the ‘main formula’ setting becomes the product’s price.

Leave it empty and you will get a ‘*0.00*‘ price; fill it with any valid math expression and you can “build” your product price. Putting only a number also works (e.g. ‘*42*‘).

Math formula can be as simple as the following one:

{uni_cpo_width}*{uni_cpo_height}*0.12

Or it may be as complex as:

({uni_cpo_width}*{uni_cpo_height}*{uni_nov_cpo_base_price})+{uni_cpo_thickness}*2.12+round(max({uni_cpo_acc1}, {uni_cpo_acc2}, {uni_cpo_acc3}))

Or even more complex!

Please note: **variables inside the curly brackets are product custom fields**. Those that begin with ‘*uni_cpo_*‘ are regular variables from the custom options added to the product.

Which brings us to the next note: **Uni CPO plugin also lets you add custom product options by using a visual form builder.**

Each regular variable holds the value of its option. Those that start with ‘*uni_nov_cpo_*‘ are numeric variables, created without any connection to options. It is possible to create a lot of artificial variables – in the plugin I call them NOVs (abbr for “*non-option variables*“) – and each can hold its part of the formula.

It is also possible to re-use NOVs in other NOVs and create a cascading effect.

## Custom functions and NOV matrixes

You may have noticed that I used known math functions in the previous examples: ‘*round*‘ and ‘*max*‘. That’s right, and you can use these are functions in your formulas in the same way as you may do that in spreadsheet software.

There are more! Functions like ‘*round*‘, ‘*floor*‘ and ‘*ceil*‘ help with rounding. Functions such as ‘*min*‘ and ‘*max*‘ accept several arguments and make it possible to get the lowest and the highest number from a set of options. There are also ‘*IF*‘ statements. You can compare the option’s value against some threshold and determine if it is higher or lower and build additional logic on this.

NOV matrixes can be one or two dimensional and are used to derive a new value based on the value(s) from regular option(s) or NOV(s).

The simplest example is **table-based pricing**. Let’s say you have an option called “*Thickness*” (a dropdown of available values). Each thickness value (e.g. 4mm, 6mm etc.) has a specific price (e.g. 4mm has price $5.10, 6mm has price $8.79).

In this case, {*uni_nov_cpo_thickness*} will be holding thickness values (4 and 6 mm):

…and {*uni_nov_cpo_thickness_price*} will be holding price values:

Each option includes sub-options such as nicename, slug and price/rate settings (in our example these will be used instead of ‘1’ and ‘2’ that really don’t mean anything):

## Demo and usage examples

Uni CPO demo site features many case studies – for example “Foamex banner” or “Furniture” products. They all take advantage of math formulas in order to calculate their prices.

## Free vs PRO version

The free version of Uni CPO gives you the option to use math formulas and math functions in your product price calculations. Non-option variables are also available.

Uni CPO PRO introduces matrix functionality; therefore, it gives a possibility to create table-based pricing. Besides, it enables the product’s weight calculation and allows defining its measures; these values could be used during shipping price calculation (if your shipping plugin supports these values to be set dynamically).

The pro version includes updates and support (first response is always within 24 hours) for one year or lifetime, depending on the chosen license.