WooCommerce::call_function()
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.
Return
Mixed
. The result from the function.
Usage
$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.
Changelog
Since 4.4 | Introduced. |
WooCommerce::call_function() WooCommerce::call function code WC 9.2.3
public function call_function( $function_name, ...$parameters ) { return wc_get_container()->get( LegacyProxy::class )->call_function( $function_name, ...$parameters ); }