B
B
barmy712016-03-24 20:53:49
WordPress
barmy71, 2016-03-24 20:53:49

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

2 answer(s)
P
prishelec, 2018-04-13
@prishelec

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;
}

D
Dmitry, 2016-03-24
@LazyTalent

Ideally, write your own plugin that would display the desired price.
There is an imperfect option: insert a Java script into the footer that will change the price.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question