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

How to hide price for "out of stock" products in 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!