woocommerce_available_variation

The WooCommerce woocommerce available variation hook.

Description

apply_filters( 'woocommerce_available_variation', (array) $variation_get_max_purchase_quantity, (unknown) $instance, (unknown) $variation ); 

Parameters (3)

0. $variation_get_max_purchase_quantity — Optional. (array) => array_merge( $variation->get_data(), array( 'attributes' => $variation->get_variation_attributes(), 'image' => wc_get_product_attachment_props( $variation->get_image_id() ), 'weight_html' => wc_format_weight( $variation->get_weight() ), 'dimensions_html' => wc_format_dimensions( $variation->get_dimensions( false ) ), 'price_html' => $show_variation_price ? '' . $variation->get_price_html() . '' : '', 'availability_html' => wc_get_stock_html( $variation ), 'variation_id' => $variation->get_id(), 'variation_is_visible' => $variation->variation_is_visible(), 'variation_is_active' => $variation->variation_is_active(), 'is_purchasable' => $variation->is_purchasable(), 'display_price' => wc_get_price_to_display( $variation ), 'display_regular_price' => wc_get_price_to_display( $variation, array( 'price' => $variation->get_regular_price() ) ), 'dimensions' => wc_format_dimensions( $variation->get_dimensions( false ) ), 'min_qty' => $variation->get_min_purchase_quantity(), 'max_qty' => 0 < $variation->get_max_purchase_quantity() ? $variation->get_max_purchase_quantity() : '', 'backorders_allowed' => $variation->backorders_allowed(), 'is_in_stock' => $variation->is_in_stock(), 'is_downloadable' => $variation->is_downloadable(), 'is_virtual' => $variation->is_virtual(), 'is_sold_individually' => $variation->is_sold_individually() ? 'yes' : 'no', 'variation_description' => wc_format_content( $variation->get_description() ), ) )
The array.
1. $instance (unknown)
The instance.
2. $variation (unknown)
The variation.

Usage

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

Defined (1)

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

/includes/class-wc-product-variable.php  
  1. return apply_filters( 'woocommerce_available_variation', array_merge( $variation->get_data(), array(