Hugh Lashbrooke

Community builder by day, tabletop game designer by night.

Snippet: Check for the latest WooCommerce version

, , ,

With WooCommerce 2.1 having just been released, you’ll find that a number of functions that you have been using in your plugins and themes have now been deprecated in favour of better and more aptly named functions. Ideally, it would be great if you could just replace these functions with the new versions, but until everyone upgrades we need to cater for WooCommerce 2.1 as well as 2.0.x. With that in mind here is a simple function that uses PHP’s version_compare() function to check that a site is running the specified version of WooCommerce or higher (defaults to 2.1) along with the basic usage:

View this gist on GitHub

The function returns boolean true or false and you can specify any WooCommerce version you like for the $version parameter, but leaving it blank will check against v2.1.

To find out which of the functions that you’re using have been deprecated, switch debug mode on and you’ll see all the relevant deprecated notices appear where the functions are being used – these notices should also tell you what functions you can use in place of the old ones.

Leave a Reply

Your email address will not be published. Required fields are marked *