Logo
Three Lesser Known Tips & Tricks For Uni CPO

Think of Uni CPO WooCommerce Product Options and Price Calculation Formulas plugin as a complex system of possibilities for your product configuration, rather than one or several separated tools in a single package. Thus this system has its own bindings or features which are the result of coincidence rather than intention. Still, the following Uni CPO features – I prefer to call them features because of their importance – are so cool that they had better be invented if never existed.

Trick 1: The order of NOVs matters

I think this is the trick number 1 just because of the fact of extremely frequent use of it during product configuration. The order in which NOVs are saved matters. To put it simply, it means that you can use NOVs from top of the list in formulas/matrix for NOVs which are in the bottom of the list. This is illustrated in the following screenshot:

uni cpo tips

NOV ‘{uni_nov_cpo_width_m}‘ is created first. And I am using it in the third NOV called ‘{uni_nov_cpo_width_m_q}‘. The reason why is it possible is that NOVs are getting evaluated one by one from the top to the bottom. So, at the moment of evaluation of variable ‘{uni_nov_cpo_width_m_q}‘ the script has already evaluated variable ‘{uni_nov_cpo_width_m}‘, it computed its value and can use it to compute the value of the third variable.

Trick 2: How to connect NOV matrices with Select/Radio suboptions

Yes, it is really tricky because as you may already know that NOV matrices are meant to work with numeric values ONLY. At the same time Suboptions’ slugs, which are the unique names they can be identified with, can be text only.

uni cpo tips

So, how to combine them? The answer is using the third type of setting which is available for all the suboptions. It is called ‘price/rate’ and this is what we need. The rule is – keep them unique across suboptions of a certain option. Just like slugs, but numeric. It can be a simple sequence like “1,2,3,4…” or somewhat meaningful sequence like on the screenshot below:

uni cpo tips

In the example, my suboptions are “3 mm”, “5 mm” and “10 mm”, so I used “3”, “5” and “10” values. They are unique for my suboptions, they are not getting repeated. It is very important! Then I have chosen this my option as 2nd var in the NOV matrix and used the same values. Note that it could be set as the 1st var and those values would be in the head of the matrix columns. Actually, it is not relevant where do you put them and is totally up to you!
The reason why it works is that all options’ choices are getting transformed into numeric values for the purpose of using them in the price calculation formula. In case of Select/Radio Option such numeric values can be set in ‘price/rate’ setting. But it does not mean that they will be used anywhere automatically. They will be used only if you decide to use them and where you decide to use them. So, first, do not fear to use these settings in general. Second, try them in different combinations with other instruments such as NOVs or Formula Conditional Rules.

Trick 3: Maths functions are powerful friends

Sometimes you meet completely non-trivial product configuration and wonder if (and how if possible?) it can be achieved by using Uni CPO. Well, let me give you an example… hmm… let’s say you want to add to the product price some fixed value but a certain number of times which depends on some other option/parameter. To be more clear, let’s pretend we need to add feet to our product “Stand” according to the following rules:

  1. 2 pieces initially
  2. 1 extra if a width is more than 3 meters
  3. 1 additional every 2 meters

A width is a custom option.

So, how to achieve this?

First, let’s quickly evaluate what we have got, try to express it mathematically:

  • width < 3 = add 2
  • width > 3 and width < 5 = add 3 (2+1, I write total here)
  • width > 5 and width < 7 = add 4
  • width > 7 and width < 9 = add 5

We have got a sequence! 🙂 It can be described with the following formula: ’round({width}/2)+1′. You can see that I have used one of maths functions. The full list of available ones can be found in the documentation. How do I get this formula? By trials and errors, and deduction and … I have just kept looking and trying different ways until I have found the regularity. It might not be a perfectly precise or whatever. At least, only you decide if it is good enough. This is exactly what I have done by testing the formula in spreadsheet against all possible yet significant values of width. I think what is more important is that I can do this with Uni CPO. I do not have to write any additional single line of code. You can achieve the same as well. You do not need to hire a freelancer to do the job. The tool exists already and it is called Uni CPO WooCommerce Product Options and Price Calculation Formulas plugin 🙂

You do not need to hire a freelancer to do the job. The tool exists already and it is called Uni CPO WooCommerce Product Options and Price Calculation Formulas plugin

The final result (a real world example)

I have used two NOVs:

uni cpo tips

The first NOV calculates the number of pieces which should be added based on width parameter (just to remind: the width is a custom option; its value is set by customer). The second NOV is for a price of 1 piece of feet. Actually, it might not be needed to keep two NOVs. My final part of the product price formula is this ‘…+{uni_nov_cpo_feet_qty}*{uni_nov_cpo_feet_price}’, but I could keep it like this ‘…+{uni_nov_cpo_feet_qty}*24}’. The real reason why I use the second NOV is to achieve wholesale pricing functionality. It is not shown on the screenshot, but yes – wholesale functionality is also possible with Uni CPO plugin!