Skip to content

Instantly share code, notes, and snippets.

@hlashbrooke
Last active December 13, 2023 12:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hlashbrooke/9133402 to your computer and use it in GitHub Desktop.
Save hlashbrooke/9133402 to your computer and use it in GitHub Desktop.
WooCommerce - Check if you are running a specified WooCommerce version (or higher)
<?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;
}
?>
<?php
if( woocommerce_version_check() ) {
// Use new, updated functions
} else {
// Use older, deprecated functions
}
?>
@passatgt
Copy link

<?php echo WC()->version; ?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment