How to display variable prices by default in woocommerce?

I would like to display the variable price by default in the “from price tab” in the single product page. and not have the from price.

Its confusing to the shopper to see a “from” price then below it a price for each variation, that changes once a variation is chosen.

see attached image

So instead of having to sets of price fields I want to display only one where its a single or variable product.

enter image description here

2 Answers
2

The function woocommerce_template_single_price() handling the display of the “normal” price is pluggable, which means it can be overridden putting this into your functions.php:

//override woocommerce function
function woocommerce_template_single_price() {
    global $product;
    if ( ! $product->is_type('variable') ) { 
        woocommerce_get_template( 'single-product/price.php' );
    }
}

This works because in woocommerce-template.php the functions gets initiated like this:

if ( ! function_exists( 'woocommerce_template_single_price' ) ) {
    function woocommerce_template_single_price() {
        woocommerce_get_template( 'single-product/price.php' );
    }
}

As you can see the conditional says if the function not exists, but the function already exists. The one we put into the functions.php will be used, because it is initiated earlier.

To show the the variation price when a single product page with a variable product is loaded, you have to select a default product variation on the product edit page.

Leave a Comment