Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Hide Prices on WooCommerce Shop and Category Pages

As a store owner or digital marketer, prices are your best friend and your worst enemy — depending on where and how you use them. While generally, it’s a good idea to display prices upfront, sometimes the marketing strategy dictates otherwise.

There’s an interesting use case one of our clients came to us with recently. They wanted to hide prices on the shop and category pages of their WooCommerce store, prompting the customer to click on a product to find out its price.

We saw in a previous post how to hide products from certain categories on the shop page. In this post, we will see how to hide the prices on the category archive pages and shop page.

Hide prices on category archive pages:

How to Hide Prices on WooCommerce Shop and Category Pages - Tyche Softwares

The above image shows the ‘Urban’ category archive page. The prices are displayed below the product title.

Getting this done is very simple, actually. All you need is less than 10 lines of PHP code, explained in the snippet below:

/**
 * Snippet 1: Hide prices on all categories
 * Created by: Tyche Softwares
 */

function tyches_hide_prices_on_all_categories( $price, $product ) {
  if ( is_product_category() ) {
    return ''; // Empty string = no price!
  }
    
  return $price;
}

add_filter( 'woocommerce_get_price_html', 'tyches_hide_prices_on_all_categories', 10, 2 );

In this example, we have used the WooCommerce filter ‘woocommerce_get_price_html‘ which is located in the file – abstract-wc-product.php

This function accepts 2 parameters – $price & $product. We can modify our price from here and return it. If we want to hide the price for all the category archive pages, we use the function is_product_category()This function checks if the current page is a product category or tags archive page and if it is then set the $price as blank on all the product category & tags archive pages.

Here is the ‘Urban’ category archive page after hiding the prices –

Hide Prices on all category pages
Hide Prices on all category pages

This function is only for the display purpose and won’t affect the actual prices of the products.

If you want to hide the price of a specific category only, then you can pass the slug of the category to the is_product_category() function. Here is an example –

/**
 * Snippet 1: Hide prices on all categories
 * Created by: Tyche Softwares
 */

function tyches_hide_prices_on_all_categories( $price, $product ) {
  if ( is_product_category('urban') ) {
    return ''; // Empty string = no price!
  }
    
  return $price;
}

add_filter( 'woocommerce_get_price_html', 'tyches_hide_prices_on_all_categories', 10, 2 );

In this example, only the ‘Urban’ product category’s archive page will hide the prices. The price on other categories will be displayed.

You can also use the WorPress function is_tax() which returns true when the current page is a category or tags archive page. However, for the product categories, we will pass the ‘product_cat’ as a parameter to this function to identify it as a product category.

Here is the same example with is_tax() function-

/**
 * Snippet 1: Hide prices on all categories
 * Created by: Tyche Softwares
 */
function tyches_hide_prices_on_all_categories( $price, $product ) {
  if ( is_tax('product_cat', 'urban' ) ) {
    return ''; // Empty string = no price!
  }
    
  return $price;
}
  

add_filter( 'woocommerce_get_price_html', 'tyches_hide_prices_on_all_categories', 10, 2 );

Hide prices on Shop page:

The method to hide the price from the shop page is same as above. If we want to hide the price only on the shop page,we can use the function is_shop() to check if the current page is a shop page or not. If it is then we return the price as blank.

function tyches_hide_prices_on_all_categories( $price, $product ) {
  if ( is_shop() ) {
    return ''; // Empty string = no price!
  }
    
  return $price;
}
  
add_filter( 'woocommerce_get_price_html', 'tyches_hide_prices_on_all_categories', 10, 2 );

Here is the shop page after the prices are hidden –

Hide prices on shop page
Hide prices on shop page

If we want all the archive pages like shop page, category pages, tags pages to hide the prices, then we will just return the blank price without checking for any condition.

function tyches_hide_prices_on_all_categories( $price, $product ) {
  return '';
}
add_filter( 'woocommerce_get_price_html', 'tyches_hide_prices_on_all_categories', 10, 2 );

Yes, that’s all there is to it!  As usual, you need to add them to the active theme’s functions.php file. You can refer to this post on our site that describes 5 ways to add custom code to WordPress website.

Browse more in: WooCommerce Tutorials, Code Snippets, WooCommerce How Tos

Share It:

Subscribe
Notify of
9 Comments
Newest
Oldest
Inline Feedbacks
View all comments
1 year ago

hello how to hide prices in products section

Nikola Durdíková
2 years ago

Hello,

I would like to hide all the prices in cart and checkout.

Is it possible?
Thanks

Rich
2 years ago

Thanks for this information, worked like a charm! Maybe consider adding instructions earlier on in the article about where exactly to add the code. I was lost until I read the very last line stating to add it in the functions.php file. All good now. 🙂

3 years ago

I just wanted the prices hidden on the shop page and this worked perfect. The ugly “spread” of prices “$1.00 – $5,000.00” display style is soooo tacky. You’re great. Thank you!

Sam Weinstein
3 years ago

I am looking for a way to hide the price of any product of a specific category on the shop page all other products of other categories should have their price displayed.

9
0
Would love your thoughts, please comment.x
()
x