Hello Team,
and great work with this plugin, been looking and awaiting a long time for such a jewel :)
(the website i'm working on is using savoy theme, latest version)
I have a small issue though, I made a rule to display the prices without VAT for B2B users,
+ a rule to NOT display some variations to Guest and B2C. (price hide)
and when I do so, the variable products would show by default the price range which I didn't want to, so I looked around and found a snippet to achieve what I want.
Works almost everywhere but on the related-sells product block display, it doesn't show a the price when it's a variable product. (price is shown when simple product)
(and also when I call a product with this shortcode, no prices show up.)
[product id="xxx"]
Here's my snippet :
/* B2B King : hide Price range on variable products
=============================================================== */
function iconic_format_price_range( $price, $from, $to ) {
return ' '.wc_price( $from );
}
add_filter( 'woocommerce_format_price_range', 'iconic_format_price_range', 10, 3 );
/* WOO Remove Price Range for variable products.
* https://annaschneider.me/blog/hide-the-price-range-for-woocommerce-variable-products/
// =============================================================== */
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] && is_product()) {
$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;
}
// Move Variations price above variations to have the same template even if variations prices are the same
remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
add_action( 'woocommerce_before_variations_form', 'woocommerce_single_variation', 10 );
if you could kindly give an eye on this, i guess there's a parameter for related-product to follow the same price display than the rest of the shop, but it's getting out of my skills to solve this alone.
Many thanks in advance,
Robin.








