2
votes

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? Thanks in advance.

3
Welcome to stackoverflow! What have you tried? any code to share? - fotanus
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
(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
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?. - Xavi López

3 Answers

5
votes

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

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);
-5
votes
.price{ display:none !important;}