WC()WC 2.1

Main instance of WooCommerce.

No Hooks.

Return

WooCommerce.

Usage

WC();

Examples

1

#1 Explanation of how the function works [auto-translate]

The initial object is formed by calling the function in the main plugin file woocommerce.php:

function WC() {
	return WooCommerce::instance();
}

$GLOBALS['woocommerce'] = WC();

For backward compatibility, the class object is placed in the $GLOBALS superglobal array, meaning the two WooCommerce version retrieval constructs are identical:

// Recommended method
$version = WC()->version

// The old way
$version = $GLOBALS['woocommerce']->version;
0

#2 Demo

The WC() function is a wrapper for the WooCommerce class, so see there for examples of use.

Changelog

Since 2.1 Introduced.

WC() code WC 9.4.2

function WC() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	return WooCommerce::instance();
}