- availability:
-
WooCommerce Multilingual Version: 3.8
- description:
-
Add filters to check if a product is variable. This is useful for WooCommerce extensions that have their own variable product types.
- type:
- filter
- category:
- Miscellaneous
- parameters:
-
add_filter( 'wcml_is_variable_product', 'the_callback_function', 10, 2 );
There are two parameters passed to this filter:
- $is_variable
- (bool) Whether or not the product is variable.
- $product_id
- (integer) The product ID.
- hook example usage:
-
Example
/** * This example is extracted from the Adventure Tours compatibility class in the WCML code. */ add_filter( 'wcml_is_variable_product', 'is_variable_tour', 10, 2 ); function is_variable_tour( $is_variable, $product_id ){ $var_tour_meta = get_post_meta( $product_id, '_variable_tour', true ); if( $is_variable && $var_tour_meta == 'yes' ){ $is_variable = true; }elseif( $var_tour_meta == 'no' ){ $is_variable = false; } return $is_variable; }