WordPress at Your Fingertips
function is not described

WooCommerce::get_instance_of() public WC 4.4

Gets an instance of a given legacy class. This must not be used to get instances of classes in the src directory.

This method can be useful for unit tests, since objects obtained using this method can be easily mocked by using WC_Unit_Test_Case::register_legacy_proxy_class_mocks.

{} It's a method of the class: WooCommerce{}

No Hooks.

Return

Object. The instance of the class.

Usage

$WooCommerce = new WooCommerce();
$WooCommerce->get_instance_of( $class_name, ...$args );
$class_name(string) (required)
The name of the class to get an instance for.
...$args(mixed) (required)
Parameters to be passed to the class constructor or to the appropriate internal 'get_instance_of_' method.

Changelog

Since 4.4 Introduced.

Code of WooCommerce::get_instance_of() WC 5.6.0

public function get_instance_of( string $class_name, ...$args ) {
	return wc_get_container()->get( LegacyProxy::class )->get_instance_of( $class_name, ...$args );
}