woocommerce_show_variation_price filter-hookWC 2.4.0

Filter whether to show variation price. Replicates the filter from WC_Product_Variable::get_available_variation().

Usage

add_filter( 'woocommerce_show_variation_price', 'wp_kama_woocommerce_show_variation_price_filter', 10, 3 );

/**
 * Function for `woocommerce_show_variation_price` filter-hook.
 * 
 * @param bool                  $show_price Whether to show the price.
 * @param \WC_Product_Variable  $product    The variable product.
 * @param \WC_Product_Variation $variation  The variation.
 *
 * @return bool
 */
function wp_kama_woocommerce_show_variation_price_filter( $show_price, $product, $variation ){

	// filter...
	return $show_price;
}
$show_price(true|false)
Whether to show the price.
$product(\WC_Product_Variable)
The variable product.
$variation(\WC_Product_Variation)
The variation.

Changelog

Since 2.4.0 Introduced.

Where the hook is called

ProductPrice::render()
woocommerce_show_variation_price
WC_Product_Variable::get_available_variation()
woocommerce_show_variation_price
woocommerce/src/Blocks/BlockTypes/ProductPrice.php 104-109
$show_variation_price = apply_filters(
	'woocommerce_show_variation_price',
	true,
	$product,
	$variation
);
woocommerce/includes/class-wc-product-variable.php 420
$show_variation_price = apply_filters( 'woocommerce_show_variation_price', $variation->get_price() === '' || $this->get_variation_sale_price( 'min' ) !== $this->get_variation_sale_price( 'max' ) || $this->get_variation_regular_price( 'min' ) !== $this->get_variation_regular_price( 'max' ), $this, $variation );

Where the hook is used in WooCommerce

Usage not found.