woocommerce_rest_(post_type)_object_trashable filter-hookWC 1.0

Filter whether an object is trashable.

Return false to disable trash support for the object.

Usage

add_filter( 'woocommerce_rest_(post_type)_object_trashable', 'wp_kama_woocommerce_rest_post_type_object_trashable_filter', 10, 2 );

/**
 * Function for `woocommerce_rest_(post_type)_object_trashable` filter-hook.
 * 
 * @param boolean $supports_trash Whether the object type support trashing.
 * @param WC_Data $object         The object being considered for trashing support.
 *
 * @return boolean
 */
function wp_kama_woocommerce_rest_post_type_object_trashable_filter( $supports_trash, $object ){

	// filter...
	return $supports_trash;
}
$supports_trash(true|false)
Whether the object type support trashing.
$object(WC_Data)
The object being considered for trashing support.

Where the hook is called

WC_REST_Products_V2_Controller::delete_item()
woocommerce_rest_(post_type)_object_trashable
WC_REST_Product_Variations_V2_Controller::delete_item()
woocommerce_rest_(post_type)_object_trashable
WC_REST_CRUD_Controller::delete_item()
woocommerce_rest_(post_type)_object_trashable
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php 1568
$supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php 509
$supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object );
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-crud-controller.php 460
$supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object );

Where the hook is used in WooCommerce

woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php 53
add_filter( "woocommerce_rest_{$this->post_type}_object_trashable", '__return_false' );