woocommerce_rest_pre_insert_(post_type)_object filter-hookWC 1.0

Filters an object before it is inserted via the REST API.

The dynamic portion of the hook name, $this->post_type, refers to the object type slug.

Usage

add_filter( 'woocommerce_rest_pre_insert_(post_type)_object', 'wp_kama_woocommerce_rest_pre_insert_post_type_object_filter', 10, 3 );

/**
 * Function for `woocommerce_rest_pre_insert_(post_type)_object` filter-hook.
 * 
 * @param WC_Data         $product  Object object.
 * @param WP_REST_Request $request  Request object.
 * @param bool            $creating If is creating a new object.
 *
 * @return WC_Data
 */
function wp_kama_woocommerce_rest_pre_insert_post_type_object_filter( $product, $request, $creating ){

	// filter...
	return $product;
}
$product(WC_Data)
Object object.
$request(WP_REST_Request)
Request object.
$creating(true|false)
If is creating a new object.

Where the hook is called

WC_REST_Products_V2_Controller::prepare_object_for_database()
woocommerce_rest_pre_insert_(post_type)_object
WC_REST_Product_Variations_V2_Controller::prepare_object_for_database()
woocommerce_rest_pre_insert_(post_type)_object
WC_REST_Orders_V2_Controller::prepare_object_for_database()
woocommerce_rest_pre_insert_(post_type)_object
WC_REST_Order_Refunds_V2_Controller::prepare_object_for_database()
woocommerce_rest_pre_insert_(post_type)_object
WC_REST_Coupons_V2_Controller::prepare_object_for_database()
woocommerce_rest_pre_insert_(post_type)_object
WC_REST_Products_Controller::prepare_object_for_database()
woocommerce_rest_pre_insert_(post_type)_object
WC_REST_Product_Variations_Controller::prepare_object_for_database()
woocommerce_rest_pre_insert_(post_type)_object
WC_REST_Orders_Controller::prepare_object_for_database()
woocommerce_rest_pre_insert_(post_type)_object
WC_REST_Order_Refunds_Controller::prepare_object_for_database()
woocommerce_rest_pre_insert_(post_type)_object
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php 1277
return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $product, $request, $creating );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php 517
return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $variation, $request, $creating );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php 756
return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $order, $request, $creating );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php 327
$refund = apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $refund, $request, $creating );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-coupons-v2-controller.php 324
return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $coupon, $request, $creating );
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php 896
return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $product, $request, $creating );
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-variations-controller.php 392
return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $variation, $request, $creating );
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-orders-controller.php 170
return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $order, $request, $creating );
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-order-refunds-controller.php 88
return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $refund, $request, $creating );

Where the hook is used in WooCommerce

Usage not found.