WooCommerce - Check if you are running a specified WooCommerce version (or higher)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function woocommerce_version_check( $version = '2.1' ) { | |
if ( function_exists( 'is_woocommerce_active' ) && is_woocommerce_active() ) { | |
global $woocommerce; | |
if( version_compare( $woocommerce->version, $version, ">=" ) ) { | |
return true; | |
} | |
} | |
return false; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( woocommerce_version_check() ) { | |
// Use new, updated functions | |
} else { | |
// Use older, deprecated functions | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this function is_woocommerce_active() no longer exists. So i prefer to check if class exists, like this: