2

When I create a woocommerce product with variations such as a t-shirt with different sizes, the product page shows a "from" price. As the products all have the same prices I don't need to display the from price. I just want to remove the from price and then when the user makes a choice in the selectbox, the price will appear.

How can I remove the variation price?

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
McAsh
  • 215
  • 2
  • 4
  • 11
  • Welcome to stackoverflow! What have you tried? any code to share? – fotanus May 03 '13 at 22:20
  • Thanks :) I've tried editing several template files within woocommerce. The problem is, I'm not sure from which file the variation price is output. However, I believe it would be natural if it was inside woocommerce -> classes -> class-wc-product-variable.php. In this file I've tried removing line 234-292. – McAsh May 04 '13 at 19:33
  • (I don't have characters enough to display the code I removed). Sry, I'm still a newb when it comes to Stack Overflow :) – McAsh May 04 '13 at 19:34
  • As pointed out by @bazinga in a deleted answer, It seems though that this answer works for some people: [How to display variable prices by default in woocommerce?](http://wordpress.stackexchange.com/q/117418). – Xavi López Nov 25 '13 at 13:00

3 Answers3

5

Add this to functions.php

add_filter('woocommerce_variable_price_html','custom_from',10);
add_filter('woocommerce_grouped_price_html','custom_from',10);
add_filter('woocommerce_variable_sale_price_html','custom_from',10);
function custom_from($price){
    return false;
}
Joe
  • 15,205
  • 8
  • 49
  • 56
Robaggs
  • 173
  • 1
  • 5
-1

Just copy and paste below code for your theme function.php file.

function patricks_custom_variation_price( $price, $product ) {

    $target_product_types = array(
        'variable'
    );

    if ( in_array ( $product->product_type, $target_product_types ) ) {
        // if variable product return and empty string
        return '';
    }

    // return normal price
    return $price;
}

add_filter('woocommerce_get_price_html', 'patricks_custom_variation_price', 10, 2);
Tom
  • 16,842
  • 17
  • 45
  • 54
vino
  • 302
  • 4
  • 18
-5
.price{ display:none !important;}
LaurentG
  • 11,128
  • 9
  • 51
  • 66
Sp.
  • 136
  • 1
  • 5
  • This doesn't work, since it also hides the price for products without flexible pricing. – ejazz Sep 18 '14 at 12:04