woocommerce_rest_insert_product хук-событиеWC 1.0

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

Использование

add_action( 'woocommerce_rest_insert_product', 'wp_kama_woocommerce_rest_insert_product_action', 10, 3 );

/**
 * Function for `woocommerce_rest_insert_product` action-hook.
 * 
 * @param WP_Post         $post     Post data.
 * @param WP_REST_Request $request  Request object.
 * @param boolean         $creating True when creating item, false when updating.
 *
 * @return void
 */
function wp_kama_woocommerce_rest_insert_product_action( $post, $request, $creating ){

	// action...
}
$post(WP_Post)
Post data.
$request(WP_REST_Request)
Request object.
$creating(true|false)
True when creating item, false when updating.

Где вызывается хук

WC_REST_Products_V1_Controller::create_item()
woocommerce_rest_insert_product
WC_REST_Products_V1_Controller::update_item()
woocommerce_rest_insert_product
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-products-v1-controller.php 757
do_action( 'woocommerce_rest_insert_product', $post, $request, true );
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-products-v1-controller.php 800
do_action( 'woocommerce_rest_insert_product', $post, $request, false );

Где используется хук в WooCommerce

woocommerce/src/Internal/ProductAttributesLookup/LookupDataStore.php 54
self::add_action( 'woocommerce_rest_insert_product', array( $this, 'on_product_created_or_updated_via_rest_api' ), 100, 2 );