woocommerce_variation_is_visible

Checks if this particular variation is visible.

Description

apply_filters( 'woocommerce_variation_is_visible', (string) $publish_get_post_status_this_get_id_this_get_price, (unknown) $this_get_id, (unknown) $this_get_parent_id, (unknown) $instance ); 

Invisible variations are enabled and can be selected, but no price / stock info is displayed. Instead, a suitable unavailable message is displayed. Invisible by default: Disabled variations and variations with an empty price.

Parameters (4)

0. $publish_get_post_status_this_get_id_this_get_price — Optional. (string) => 'publish' === get_post_status( $this->get_id() ) && '' !== $this->get_price()
The publish get post status this get id this get price.
1. $this_get_id (unknown)
The this get id.
2. $this_get_parent_id (unknown)
The this get parent id.
3. $instance (unknown)
The instance.

Usage

To run the hook, copy the example below.
  1. $publish_get_post_status_this_get_id_this_get_price = apply_filters( 'woocommerce_variation_is_visible', $publish_get_post_status_this_get_id_this_get_price, $this_get_id, $this_get_parent_id, $instance ); 
  2.  
  3. if ( !empty( $publish_get_post_status_this_get_id_this_get_price ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_variation_is_visible callback 
  2. function filter_woocommerce_variation_is_visible( $publish_get_post_status_this_get_id_this_get_price, $this_get_id, $this_get_parent_id, $instance ) { 
  3. // make filter magic happen here... 
  4. return $publish_get_post_status_this_get_id_this_get_price
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'woocommerce_variation_is_visible', 'filter_woocommerce_variation_is_visible', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'woocommerce_variation_is_visible', 'filter_woocommerce_variation_is_visible', 10, 4 ); 

Defined (1)

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

/includes/class-wc-product-variation.php  
  1. return apply_filters( 'woocommerce_variation_is_visible', 'publish' === get_post_status( $this->get_id() ) && '' !== $this->get_price(), $this->get_id(), $this->get_parent_id(), $this );