woocommerce_rest_insert_<post_type>

Fires after a single item is created or updated via the REST API.

Description

do_action( 'woocommerce_rest_insert_<post_type>', (WP_Post) $post, (WP_REST_Request) $request, (bool) $true ); 

Parameters (3)

0. $post (WP_Post)
Inserted object.
1. $request (WP_REST_Request)
Request object.
2. $true (bool) => true
True when creating item, false when updating.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'woocommerce_rest_insert_{$post_type}', $post, $request, $true ); 
The following example is for adding a hook callback.
  1. // define the woocommerce_rest_insert_<post_type> callback 
  2. function action_woocommerce_rest_insert_post_type( $post, $request, $true ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( "woocommerce_rest_insert_{$post_type}", 'action_woocommerce_rest_insert_post_type', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( "woocommerce_rest_insert_{$post_type}", 'action_woocommerce_rest_insert_post_type', 10, 3 ); 

Defined (9)

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

/includes/api/v1/class-wc-rest-webhooks-controller.php  
  1. do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true ); 
  1. do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, false ); 
/includes/api/v1/class-wc-rest-orders-controller.php  
  1. do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true ); 
  1. do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, false ); 
/includes/api/v1/class-wc-rest-order-refunds-controller.php  
  1. do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true ); 
/includes/api/v1/class-wc-rest-coupons-controller.php  
  1. do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true ); 
  1. do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, false ); 
/includes/abstracts/abstract-wc-rest-posts-controller.php  
  1. do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true ); 
  1. do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, false );