Automattic\WooCommerce\Internal\Logging
RemoteLogger::get_wc_version
Get the current WooCommerce version reliably through a series of fallbacks
Method of the class: RemoteLogger{}
No Hooks.
Returns
String. The current WooCommerce version.
Usage
// private - for code of main (parent) class only $result = $this->get_wc_version();
RemoteLogger::get_wc_version() RemoteLogger::get wc version code WC 10.3.3
private function get_wc_version() {
if ( class_exists( '\Automattic\Jetpack\Constants' ) && method_exists( '\Automattic\Jetpack\Constants', 'get_constant' ) ) {
$wc_version = \Automattic\Jetpack\Constants::get_constant( 'WC_VERSION' );
if ( $wc_version ) {
return $wc_version;
}
}
if ( defined( 'WC_VERSION' ) ) {
return WC_VERSION;
}
if ( function_exists( 'WC' ) ) {
return WC()->version;
}
// Return null since none of the above worked.
return null;
}