How to Hide Price of “Out Of Stock” Products on WooCommerce


Recently I had the chance to help a friend who wanted to hide price of “out of stock” products on her WooCommerce store. I could not find a solution for this online with a quick search and had to mashup a filter of my own.

Hope this blog post helps those looking for a quick solution to hide prices of products that are sold out or are out of stock on their WooCommerce store.

The code:

add_filter( 'woocommerce_variable_sale_price_html', 'theanand_remove_prices', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'theanand_remove_prices', 10, 2 );
add_filter( 'woocommerce_get_price_html', 'theanand_remove_prices', 10, 2 );

function theanand_remove_prices( $price, $product ) {
if ( ! $product->is_in_stock()) {
$price = '';
return $price;

Just put this into the functions.php file of your WordPress theme and you are good to go. This will hide the price of products which are not in stock.

Good luck and happy selling!

Thoughts? Questions?

4 responses to “How to Hide Price of “Out Of Stock” Products on WooCommerce”

  1. Allen Avatar


    Wondering if a recent update broke the functionality of your code? I places the code above at the end of the functions.php file just before final closing bracket and not seeing any change to the price display.


  2. swapnil ajdhav Avatar

    great stuff just helped me a lot I am a developer and I was looking for a similar solution that you provided and your code is working absolutely fine for me
    Thank you once again 🙂

  3. Mathieu Avatar

    Great !
    Thanks a lot 😀

  4. Harsha Acharya Avatar
    Harsha Acharya

    This code works latest woocomeerce?

Leave a Reply

Your email address will not be published. Required fields are marked *