The WooCommerce plugin defines WC_VERSION php constant to tell which version it's currently at.

If you want to check and do some actions if the version of the plugin is greater that X then you can do this.

First check if the constant is defined and then use the php function version_compare() to compare the version.

if (defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '7.0') '>=' )) {
   // do something if WooCommerce version is greater than 7.0
}

If the WC_VERSION constant is not defined that means that WooCommerce plugin is not installed, activated or your code is checking too early when not all plugins were loaded by WordPress just yet.


Disclaimer: The content in this post is for educational purposes only. Always remember to take a backup before doing any of the suggested steps just to be on the safe side.
Referral Note: When you purchase through an referral link (if any) on this page, we may earn a commission.
If you're feeling thankful, you can buy me a coffee or a beer