Skip to content

Instantly share code, notes, and snippets.

@carasmo
Created January 27, 2017 21:56
Show Gist options
  • Select an option

  • Save carasmo/3b9159a0294b45c9f8948e5248a254ce to your computer and use it in GitHub Desktop.

Select an option

Save carasmo/3b9159a0294b45c9f8948e5248a254ce to your computer and use it in GitHub Desktop.
Check WooCommerce version using version_compare( WC_VERSION ...
<?php
//don't add this above
//change the hook and the function name
function yourprefix_woocommerce_function_does_what() {
if ( ! class_exists( 'WooCommerce' ) ) return;
if ( version_compare( WC_VERSION, '2.7', '>=' ) ) {
//WooCommerce 2.7 or higher
} else {
//2.6.x or under
}
}
add_action( 'some_hook' , 'yourprefix_woocommerce_function_does_what' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment