How to Hide Price Range for WooCommerce Variable Products (2 ways)

  • Post author:
  • Post published:September 14, 2021
  • Post category:WooCommerce
  • Reading time:11 mins read

If you have a WooCoomerce store, and you have added variable products to your shop. and Now you want to hide the price range for WooCommerce variable products and show only the lowest price in WooCommerce variable products.



How to Hide Price Range for WooCommerce Variable Products RealBSG
How to Hide Price Range for WooCommerce Variable Products

In this article, I’m going to show you how to hide price range for WooCommerce variable products and show only the lowest price for WooCommerce variable products, As you can see in the screenshot below, this is a WooCommerce Variable product and it displays different price range like $9.99-$39.99

02 RealBSG

But I don’t want to see the price like this, I want to display only the lowest price here.

9 RealBSG

so how we can do that?

Or Continue reading.

I will show you 2 methods that will help you to hide the price range for WooCommerce variable products and show only the lowest price in WooCommerce variable products.

  1. With a Plugin
  2. Without the plugin

I think you’re very excited to learn how we can do that, let’s get started.




Hide Price Range for WooCommerce Variable Products With a Plugin

So for this functionality, we will be using a simple and easy-to-use plugin. All you have to do is just install the plugin, Activate it, and it’s done.

Go to WordPress dashboard, Navigate to Plugins > Add New > and search for a plugin called “WooCommerce Show only lowest price

Install it, and Activate it and you have done.

03 RealBSG
04 RealBSG

Now let’s go to your WooCommerce shop.

06 RealBSG




Hide Price Range for WooCommerce Variable Products Without Plugin

You can use PHP code that will help you to hide the price range for WooCommerce variable products.

function wc_varb_price_range( $wcv_price, $product ) {




$prefix = sprintf(‘%s: ‘, __(‘From’, ‘wcvp_range’));

 

    $wcv_reg_min_price = $product->get_variation_regular_price( ‘min’, true );

    $wcv_min_sale_price = $product->get_variation_sale_price( ‘min’, true );

    $wcv_max_price = $product->get_variation_price( ‘max’, true );

    $wcv_min_price = $product->get_variation_price( ‘min’, true );




    $wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ?

        wc_price( $wcv_reg_min_price ) :

         ‘<del>’ . wc_price( $wcv_reg_min_price ) . ‘</del>’ . ‘<ins>’ . wc_price( $wcv_min_sale_price ) . ‘</ins>’;

    return ( $wcv_min_price == $wcv_max_price ) ?

        $wcv_price :

sprintf(‘%s%s’, $prefix, $wcv_price);

}


add_filter( ‘woocommerce_variable_sale_price_html’, ‘wc_varb_price_range’, 10, 2 );

add_filter( ‘woocommerce_variable_price_html’, ‘wc_varb_price_range’, 10, 2 );

All you have to do is just copy the above Code and then go to WordPress Dashboard> go to Appearance > Theme Editor > and Click functions.php, “then Past the Code” and lastly don’t forget to click the “Update file” button.

7 RealBSG

After Pasting the code.

06 RealBSG

Now we have done the job but As you can see in the image a Word “From” is also added with all the prices. So how we can remove it, copy the below code. Remove the code that we added before, add the below code, and click the “Update File” button.

function wc_varb_price_range( $wcv_price, $product ) {



    $prefix = sprintf(‘%s ‘, __(‘ ‘, ‘wcvp_range’));


    $wcv_reg_min_price = $product->get_variation_regular_price( ‘min’, true );


    $wcv_min_sale_price = $product->get_variation_sale_price( ‘min’, true );


    $wcv_max_price = $product->get_variation_price( ‘max’, true );


    $wcv_min_price = $product->get_variation_price( ‘min’, true );


    $wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ?

        wc_price( $wcv_reg_min_price ) :

        ‘<del>’ . wc_price( $wcv_reg_min_price ) . ‘</del>’ . ‘<ins>’ . wc_price( $wcv_min_sale_price ) . ‘</ins>’;


    return ( $wcv_min_price == $wcv_max_price ) ?

        $wcv_price :

        sprintf(‘%s%s’, $prefix, $wcv_price);

}


add_filter( ‘woocommerce_variable_sale_price_html’, ‘wc_varb_price_range’, 10, 2 );

add_filter( ‘woocommerce_variable_price_html’, ‘wc_varb_price_range’, 10, 2 );

and Now we have successfully removed the Word “From”. let’s go to Single Products Page.

9 RealBSG




Related Tutorial:
How To Add Quick View In WooCommerce.
How to Flip Product Image on Hover in WooCommerce.
How To Add Wishlist In WooCommerce.

I hope this tutorial will help you to hide the price range for WooCommerce variable products and show only the lowest price in WooCommerce variable products. If you want to connect with us, you can follow us on Facebook and Instagram.

If you want to buy reliable and cheap hosting for your wooCommerce store, then you can read this blog post.

FAQs (Frequently Ask Questions)

How do I hide the price range for WooCommerce variable products?
Just Install the Plugin called “WooCommerce – Show only lowest prices in variable products

How do I change the variable product price range in WooCommerce?
Yes, You can change the variable product price range in WooCommerce by just installing this Simple and easy-to-use Plugin called “WooCommerce – Show only lowest prices in variable products” and it’s done, now you have changed the variable product price range in WooCommerce.

How can I Show Only the Lowest Price in WooCommerce Variable Products?
Simply install the plugin Called “WooCommerce – Show only lowest prices in variable products” and Activate it, and it’s done, Now All your Variable products will show only the lowest price.




How can I remove the word “From”?
Yes, You can remove the word “From”, just copy the below code, and go to Appearance > Theme Editor > Click functions.php, then “Past the Below code” and click the “Update file” button.

function wc_varb_price_range( $wcv_price, $product ) {

    $prefix = sprintf(‘%s ‘, __(‘ ‘, ‘wcvp_range’));


    $wcv_reg_min_price = $product->get_variation_regular_price( ‘min’, true );

    $wcv_min_sale_price = $product->get_variation_sale_price( ‘min’, true );

    $wcv_max_price = $product->get_variation_price( ‘max’, true );

    $wcv_min_price = $product->get_variation_price( ‘min’, true );


    $wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ?

        wc_price( $wcv_reg_min_price ) :

        ‘<del>’ . wc_price( $wcv_reg_min_price ) . ‘</del>’ . ‘<ins>’ . wc_price( $wcv_min_sale_price ) . ‘</ins>’;


    return ( $wcv_min_price == $wcv_max_price ) ?

        $wcv_price :

        sprintf(‘%s%s’, $prefix, $wcv_price);

}


add_filter( ‘woocommerce_variable_sale_price_html’, ‘wc_varb_price_range’, 10, 2 ); add_filter( ‘woocommerce_variable_price_html’, ‘wc_varb_price_range’, 10, 2 );

Leave a Reply