WooCommerce::call_function()publicWC 4.4

Call a user function. This should be used to execute any non-idempotent function, especially those in the includes directory or provided by WordPress.

This method can be useful for unit tests, since functions called using this method can be easily mocked by using WC_Unit_Test_Case::register_legacy_proxy_function_mocks.

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

No Hooks.


Mixed. The result from the function.


$WooCommerce = new WooCommerce();
$WooCommerce->call_function( $function_name, ...$parameters );
$function_name(string) (required)
The function to execute.
...$parameters(mixed) (required)
The parameters to pass to the function.


Since 4.4 Introduced.

Code of WooCommerce::call_function() WC 6.5.1

public function call_function( $function_name, ...$parameters ) {
	return wc_get_container()->get( LegacyProxy::class )->call_function( $function_name, ...$parameters );