Answer the question
In order to leave comments, you need to log in
How to display the specific price of a woocommerce variable product, not a range?
Hello!
How can the following point be implemented (in order):
1. there is a variable product that, depending on the change in the attribute (product color), changes the price;
2. on the catalog page, the product under the name, respectively, displays a price range, which is not good for the task;
3. there is an option (found on the web, and consisting of adding lines to functions.php) to implement the output of the price in the format "from" minimum price ", but this is also not suitable for achieving the desired goal;
4. the question itself: how to do this, so that the price of a specific variation is displayed under the product, the one that is specified in the product variations settings by default? Thanks in advance for
your
help
!
Answer the question
In order to leave comments, you need to log in
Add to theme's functions.php
add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
function wc_wc20_variation_price_format( $price, $product ) {
$price = wc_price( min( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) ) );
return $price;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question