carasmo
1/27/2017 - 9:56 PM

Check WooCommerce version using version_compare( WC_VERSION ...

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' );