(hook_prefix)object_trashable filter-hookWC 10.2.0

Filter whether an object is trashable.

Usage

add_filter( '(hook_prefix)object_trashable', 'wp_kama_hook_prefixobject_trashable_filter', 10, 2 );

/**
 * Function for `(hook_prefix)object_trashable` filter-hook.
 * 
 * @param boolean  $supports_trash Whether the object type support trashing.
 * @param WC_Order $order          The object being considered for trashing support.
 *
 * @return boolean
 */
function wp_kama_hook_prefixobject_trashable_filter( $supports_trash, $order ){

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

Changelog

Since 10.2.0 Introduced.

Where the hook is called

Controller::delete_item()
woocommerce/src/Internal/RestApi/Routes/V4/Orders/Controller.php 428
$supports_trash = apply_filters( $this->get_hook_prefix() . 'object_trashable', EMPTY_TRASH_DAYS > 0, $order );

Where the hook is used in WooCommerce

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