Archived topic
How to remove price range display on product overview page?
3 replies · Started by Jesper on November 21, 2019
Hi
I use wooocommerce, how to remove price range display on product overview page for variance products?
Thanks
Jesper
Hi there,
Have you figured this out?
Just checked your page and don't think I'm seeing it anywhere.
Let me know :)
Hey,
for anybody who it may concern, I found this code:
//Remove Price Range
add_filter( 'woocommerce_variable_sale_price_html', 'detect_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'detect_variation_price_format', 10, 2 );
function detect_variation_price_format( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
if ($prices[0] !== $prices[1]) {
$price = $prices[0] !== $prices[1] ? sprintf( __( '', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
}
// Sale Price
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( '', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
if ( $price !== $saleprice ) {
$price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>';
}
return $price;
}
from
https://annaschneider.me/hide-the-price-range-for-woocommerce-variable-products/
I just added it to my child-theme and it works.
GLad to hear and thanks for sharing :)