woocommerce_rest_<post_type>_object_trashable

Filter whether an object is trashable.

Description

apply_filters( 'woocommerce_rest_<post_type>_object_trashable', (boolean) $supports_trash, (WC_Data) $object ); 

Return false to disable trash support for the object.

Parameters (2)

0. $supports_trash (boolean)
Whether the object type support trashing.
1. $object (WC_Data)
The object being considered for trashing support.

Usage

To run the hook, copy the example below.
  1. $supports_trash = apply_filters( 'woocommerce_rest_{$post_type}_object_trashable', $supports_trash, $object ); 
  2.  
  3. if ( !empty( $supports_trash ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_rest_<post_type>_object_trashable callback 
  2. function filter_woocommerce_rest_post_type_object_trashable( $supports_trash, $object ) { 
  3. // make filter magic happen here... 
  4. return $supports_trash
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "woocommerce_rest_{$post_type}_object_trashable", 'filter_woocommerce_rest_post_type_object_trashable', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "woocommerce_rest_{$post_type}_object_trashable", 'filter_woocommerce_rest_post_type_object_trashable', 10, 2 ); 

Defined (3)

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

/includes/api/class-wc-rest-products-controller.php  
  1. $supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object ); 
/includes/api/class-wc-rest-product-variations-controller.php  
  1. $supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object ); 
/includes/abstracts/abstract-wc-rest-crud-controller.php  
  1. $supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object );