How to Hide Price Range for WooCommerce Variable Products

How to Hide Price Range for WooCommerce Variable Products

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

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 lowest price for WooCommerce variable products, As you can see in the screenshot below, this is a WooCommerce Variable producs and it display different price range like $9.99-$39.99

Hide Price Range for WooCommerce Variable Products


But we don't want to display the price like this, we want to display only the lowest price in WooCommerce Variable products

so how we can do that?


Or Continue reading.


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

1. With a Plugin

2. Without 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, Then go to Plugins > Add New and search for "WooCommerce Show only lowest price"

Install it, and Activate it and you have done.


Hide Price Range for WooCommerce Variable Products



Hide Price Range for WooCommerce Variable Products


Now let's go to your WooCommerce shop.

Hide Price Range for WooCommerce Variable Products

Hide Price Range for WooCommerce Variable Products Without Plugin

You can use below PHP code that will help you to hide price range for WooCommerce variable products. All you have to do is just Copy the Code, and then go to WordPress Dashboard> go to Appearance > Theme Editor > and Click functions.php, "then Past the Code" and lastly don't forgot to Click the "Update file" button.


Hide 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 );



After Pasting the code.

Hide Price Range for WooCommerce Variable Products


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. Below I have added another php code. So remove the first one code, that we have add before, and Add this new one. and click "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.

Hide Price Range for WooCommerce Variable Products

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


FAQs (Frequently Ask Questions)


1. How do I hide price range for WooCommerce variable products?

Just Install the Plugin called "WooCommerce – Show only lowest prices in variable products


2. 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 can change the variable product price range in WooCommerce.


3. How can I Show Only 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.


4. 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 );



Post a Comment

Previous Post Next Post