woocommerce_api_server_before_serve

Handle serving an API request.

Description

do_action( 'woocommerce_api_server_before_serve', (unknown) $instance ); 

Matches the current server URI to a route and runs the first matching callback then outputs a JSON representation of the returned value.

Parameters (1)

0. $instance (unknown)
The instance.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'woocommerce_api_server_before_serve', $instance ); 
The following example is for adding a hook callback.
  1. // define the woocommerce_api_server_before_serve callback 
  2. function action_woocommerce_api_server_before_serve( $instance ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( 'woocommerce_api_server_before_serve', 'action_woocommerce_api_server_before_serve', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( 'woocommerce_api_server_before_serve', 'action_woocommerce_api_server_before_serve', 10, 1 ); 

Defined (3)

The action is defined in the following location(s).

/includes/api/legacy/v3/class-wc-api-server.php  
  1. do_action( 'woocommerce_api_server_before_serve', $this ); 
/includes/api/legacy/v2/class-wc-api-server.php  
  1. do_action( 'woocommerce_api_server_before_serve', $this ); 
/includes/api/legacy/v1/class-wc-api-server.php  
  1. do_action( 'woocommerce_api_server_before_serve', $this );