Variable price range
-
Hello, I would like to disable showing variable products price range. I found a code below and it works.
//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 ) );
$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 = ‘‘ . $saleprice . ‘‘ . $price . ‘‘;
}return ;
}But there is an issue when variable products are all the same price (say only different color) and don’t have the discounts, it seem to use the price range position to show the variations price.
this is strange as single product without variations uses some different position which is not affected by above code, but variable products with same price seem to show price as single product template on top of varioations, rather then below when price is different.
However, when variable products are prices differently or have a discount then variations price would appear below variations additionally to price range.Is it possible to amend this logic somehow? to show variation price below variations even if all of them have the same price?
to show variations price always below variations to keep template the same style for all products and have separate price range on top showing only if product have different prices for variations, ideally with option to hide it.
Or please advise any alternative on how to remove variation price range from the product page.
Thank you
- The topic ‘Variable price range’ is closed to new replies.