How to exclude a variable price from the WooCommerce price filter?

I need to remove one specific variable price from the price filter and for the WooCommerce order by price.

I have 4 variable product, and I don't want to show one variable attribute that contains the price $495 for all products in the price filter.

I just want to hide this specific attribute so it will not be counted in the price filter as well as in the wordpress order by price.

Thank you.

Solutions

You will need something like this:

add_filter( 'woocommerce_sale_price_html',           'custom_remove_price_html', 20, 2 );
add_filter( 'woocommerce_price_html',                'custom_remove_price_html', 20, 2 );
add_filter( 'woocommerce_empty_price_html',          'custom_remove_price_html', 20, 2 );
add_filter( 'woocommerce_variable_sale_price_html',  'custom_remove_price_html', 20, 2 );
add_filter( 'woocommerce_variable_price_html',       'custom_remove_price_html', 20, 2 );
add_filter( 'woocommerce_variable_empty_price_html', 'custom_remove_price_html', 20, 2 );
add_filter( 'woocommerce_variation_sale_price_html', 'custom_remove_price_html', 20, 2 );
add_filter( 'woocommerce_variation_price_html',      'custom_remove_price_html', 20, 2 );

function custom_remove_price_html( $price, $product ) {

    // if this is a product is a variable product.
    if ( $product->is_type( 'variable' ) ) { // updated
        // $price = '';
        return;
    }
    return $price;
}

If it doesn't work as you want, you will need to fine tune conditionals inside the function, to feet your needs.

You have to add this code snippet in the functions.php file of your active theme (or better of your active child theme ) .

Similar questions

Variable product price not showing in listing and details page WooCommerce Price Based on Country
When the product is listed in Product listing page or Product details page, The price not showing.When I click on any variation like color,then only the product price is displayed.If I deactivate the plug-in its all works good. Note: I am using All the products are variable products(color). I surfed on net for this and found something like this *Wo...
Replace the Variable Price range by the chosen variation price in WooCommerce 3
On WooCommerce I would like to change the Variable single product page layout. Because, when you have an variable product you get this wired price rage ( below product title ) in the Variable Product page and it shows in the shop page as well. For me the standard way is to show the lowest price of the product in the shop as well as product page and...
Replace variable products price range with "From:" + lowest price in WooCommerce
In WooCommerce when a Variable product has variations with different prices it displays a price range with 2 amounts: For example 89.00 - 109.00. I'd like to change it, displaying only "From: " and the lowest price like for example From: 89.00 (removing the Max price). ("Fra: " means from in my language, just to clarify). Here is the code that I ha...
Display normal price or variable price range in Woocommerce
I've a list of products and I've a problem about displaying the range of prices in variable products. As you can see if the price is a normal price everything works. Nevertheless if the product has a variable price the price displayed is 0€ Well, the code for displaying price is this: Any idea about how to display the variable range price?
Replace the Variable Price range by the chosen variation price in WooCommerce 4+
On our woocommerce website I am trying to update the displayed price based on the variations the customer selects from dropdown menus as shown here: I used a php function that had been submitted in another answer by LoictheAztec: Replace the Variable Price range by the chosen variation price in WooCommerce 3 However when a variation is selected it ...
Replace WooCommerce variable products price range with 'Up to' and the max price
I found the following code (from here) which enables me to show on a variable price product on WooCommerce: 'From: £10' (on a £10 - £50 product). I would like to effectively reverse this and show 'Up to: £50'. I have tried to tweak the code below, but just can't figure it out: This is how I would like it to look: Any help is appreciated.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .