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.

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.

WooCommerce::call_function() code WC 7.7.0

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