There are many plugins that allow you to setup special accounts for your wholesalers for example. Often times the user role feature of WordPress is used to identify users within a specific group. In this post I’ll show some examples of how you can display/hide prices for specific user groups, including only for specific products / categories.

The snippets in this post will only be for hiding prices, it will still continue users to add products to the cart.

Hiding all the prices

Lets start with a simple script first. This is a example of how you can hide all the prices no matter who is viewing.

I’ve made it so that it does still show prices on the admin, but you can easily comment that line out if you also want to hide prices there.

This code snippet hides all the prices on the product / archive pages, but not on the cart/checkout pages (or the cart widget). The following code also removes the cart item price / subtotal and the same for the checkout.

After using this code snippet it will leave the headings in the table. Unfortunately these cannot be removed with a code snippet, but there are two alternatives.

  1. By modifying the WooCommerce template files you can remove the columns from the totals table. The totals table is located in the cart/cart.php template file.
  2. You can hide them with CSS. A technical user could still uncover the product prices through, so depending on how important it is, this may or may not fit your requirements.

Here’s a CSS snippet that hides the prices on the items on the cart/checkout table and the cart widget:

/* Cart widget */
.woocommerce-mini-cart__total {
	display: none;

/* Cart */
.product-price, .product-subtotal {
	display: none !important;

/* Checkout */
.product-total *, th.product-total {
	display: none;

Again, this is not a foolproof solution.

Hiding prices for specific user roles

In the below code snippet it will hide the prices for all users with the ‘wholesale’ user role. In the sample code I’ve added multiple rows to show how you can can hide prices for different user roles. Adding more options to it is possible by following the shown format.

Hiding prices for guest users

To only hide it for guest users you can use the following simplified version;

Hiding prices in specific categories

With this version of the code snippet you can target specific categories to hide the prices for.

You can either modify the set categories to the slug of ID of the category.

If wanted you can also combine the snippets to only hide the prices in specific categories for a guest user;

Hiding prices for specific products

Here’s one last version where it only hides the prices for specific products based on the product ID.


Hope you’ve found this post helpful!

Jeroen Sormani

I'm a professional WordPress plugin developer on a mission to create the best plugins for my clients. I'm specialised in developing general WordPress, WooCommerce and Easy Digital Downloads plugins.

Interested in talking about a WordPress project? Get in touch!

Follow me on Twitter

49 thoughts on “Hiding product prices in WooCommerce

Roger Woodroofe December 6, 2017 at 5:16 am

Hey Jeroen,

Thanks for the post! This helped me out a lot getting started customising a site to selectively hide prices based on “Woocommerce Memberships” and “Categories”.


Wayne December 29, 2017 at 6:12 pm

Hi Jeroen,

Thank you. it really helped! Is it possible to hide prices for specific products on shop and single product page but display on cart, cart total and checkout?

Jeroen December 30, 2017 at 2:39 pm

Hi Wayne,

You can use these code snippets as a basis, and add some additional code to do allow them to show on the cart/checkout pages accordingly.
I don’t have something ready to go for that though.


Carrie May 2, 2018 at 7:19 pm

Hi Wayne,

Did you sort this out? I am trying to do the same thing, but haven’t yet figured it out. I see the price in the subtotal, but the price is showing as 1 rather than the actual price in the cart.

Thanks in advance for the help.

Hasan January 29, 2018 at 3:53 pm

Jeroen Hello,

First of all thank you for sharing code. I want to hide the prices of all the products on my website but I do not know where to add the codes you give. Could you please give me information? Where do I add the codes?

Jeroen January 29, 2018 at 6:05 pm

I’ve written a blog post about how you can add a code snippet to your site. You can find it here:

Brett January 31, 2018 at 6:42 am

Hi Jeroen,

I tried the ‘hiding prices in specific categories’ but it also hides the prices in the cart page for all products added to cart, not just those in the category. Any chance you can update this?

Wazo February 5, 2018 at 1:51 am

Hey amazing article!! thank you! helped me a long way. Was wondering if you can help compare the title of the product. i want to hide prices for products that have “trade” in the product title. Also have an attribute trade=yes which I can use aswellbut i dont know how to. Tried the following but it didnt work;

$page_title =get_the_title();
if (strpos($page_title, ‘Trade) !== false) {

Jarrod February 5, 2018 at 7:31 am

What does the ‘ }, 10, 2 ); ‘ do in the last line of the code to hide categories?
I’m trying to: HIDE prices UNLESS the user is logged in AND/OR the product has a TAG of ‘highlight’. I’m stumped!

Jarrod February 5, 2018 at 10:56 am

Never mind! I’ve figured it out! Thank you for an excellent resource. I wouldn’t have been able to meet my client’s request if it weren’t for this page!! Thank you!!

Rafi Ullah March 18, 2018 at 7:53 am

Good Article.
But you DIDN’T mention the exact file name / directory where you will do all these changes.
Please guide with the file names and path. so it will be very easy for beginners to hide the prices.

Thank You

Jeroen Sormani March 18, 2018 at 6:14 pm

I’ve written a blog post about how you can add a code snippet to your site. You can find it here:

Including all that information in each separate post I write with code snippets would be too much 😉

Azeem March 28, 2018 at 12:29 am

Hi Jeroen,

I tried the ‘hiding prices in specific categories’ but it also hides the prices in the cart page for all products added to cart, not just those in the category. Any chance you can update this?

Jeroen Sormani March 28, 2018 at 1:44 pm

Hi Azeem,

The content posted about hiding prices in the cart indeed only applied to all prices. The other code snippet about the categories is separated from that and shouldn’t hide any other prices. If you look at the code you’ll see it will only apply to the given product.

Maybe you also have the code that hides the prices in the cart applied before?


seoidau May 30, 2018 at 4:11 am

I can confirm that this code DOES hide line item prices in the cart and checkout pages for ALL products, not just those in the targeted category. And in the Woo Storefront theme the prices disappear in the header cart too.

Removing the code and the prices re-appear. Putting the code back in and the prices disappear.

Michele April 5, 2018 at 1:07 pm

Hello, I want replace product price with a text “Register to see price” . This only for guest. Can u help me?

Elle June 11, 2018 at 10:36 am


is it possible to hide only the prices in one language when using WPML? I have a client that sells products only within Germany but still has his onlineshop in 2 languages (german/english). So he wants to show the prices in the german translation but not in the english one.


Jeroen Sormani June 12, 2018 at 10:16 am

Hi Elle,

It is possible to create a conditional check for the language in WPML, but I don’t have that code at hand..

Tan June 12, 2018 at 5:24 pm

Hi Jeroen, thanks for the solution. I applied the code “Hiding prices for specific user roles”. At 1st it works well to hide the price for “Contributor”. I changed the function to hide the selling price to “Subscriber” instead, then the snippet seems stops functioning. Now the prices are not hidden to the “Subscriber”. Any idea what happened?

Jeroen Sormani June 13, 2018 at 8:40 am

Are you sure you’re viewing the site as a subscriber role?

Emma Olofsson June 18, 2018 at 10:50 am

Hi och thanks a lot for this! 🙂

Just one problem left, in the cart and kassa stil show the “subtotal”, can you help me hide this part as well? 🙂

Jeroen Sormani June 19, 2018 at 9:35 am

Hi Emma,

Those can be hidden with the CSS that is in the post above.

Stena July 12, 2018 at 12:30 am

Hi Jeroen, thank you very much, you give me the right code and solved my problem!

Ash July 25, 2018 at 2:58 pm

Is it possible to remove the pricing from the Woocommerce customer emails?

gabriel bau July 26, 2018 at 9:58 pm

Is it possible to change the price for soldout?

JonP August 1, 2018 at 10:19 pm

I need to remove prices from the product listings ‘shop’ page. Once the visitor gets to the product specific page it is fine.
Any advice greatly appreciated.

Jeroen Sormani August 15, 2018 at 9:22 am

Hi JonP,

I just published a blog post on my other site that shows how you can do that!


rahmi August 11, 2018 at 12:03 pm

Hi Jeroen,

First of all thank you so much for this accurate guideline.

Unfortunately, I am struggling to get it right.

I am trying to add the custom CSS for my themify theme to not show prices for the categories –> canvas, spraypaint on canvas using the the code as below:

add_filter( ‘woocommerce_get_price_html’, function( $price, $product ) {
if ( is_admin() ) return $price;
// Hide for these category slugs / IDs
$hide_for_categories = array( ‘canvas’, ‘spraypaint on canvas’ );
// Don’t show price when its in one of the categories
if ( has_term( $hide_for_categories, ‘product_cat’, $product->get_id() ) ) {
return ”;
return $price; // Return original price
}, 10, 2 );
add_filter( ‘woocommerce_cart_item_price’, ‘__return_false’ );
add_filter( ‘woocommerce_cart_item_subtotal’, ‘__return_false’ );
view raw

What am I doing wrong?

Jeroen Sormani August 15, 2018 at 9:26 am

Hi Rahmi,

Your slug for the spraypaint category is definitely incorrect, it cannot contain spaces.
Other then that I can’t really see anything wrong with the code.


Rahmi August 19, 2018 at 11:32 pm

Thank you so much, Jeroen!

Everything works like a charm now.

All the best,

Luca August 21, 2018 at 7:17 pm

Hi Jeroen,

I tried your code snippet to hide prices for a specific categories, but it hides prices in the cart and checkout page for all products, not just for the categories that I need (“medici” and “dentisti”).
Could you please help me?

Thanks in advance.
Kind Regards,

PS: Here below you can find the code snippet that I have added on my function.php:

add_filter( ‘woocommerce_get_price_html’, function( $price, $product ) {
if ( is_admin() ) return $price;
// Hide for these category slugs / IDs
$hide_for_categories = array( ‘medici’ , ‘dentisti’ );
// Don’t show price when its in one of the categories
if ( has_term( $hide_for_categories, ‘product_cat’, $product->get_id() ) ) {
return ”;
return $price; // Return original price
}, 10, 2 );

add_filter( ‘woocommerce_cart_item_price’, ‘__return_false’ );
add_filter( ‘woocommerce_cart_item_subtotal’, ‘__return_false’ );

Jeroen Sormani August 22, 2018 at 9:17 am

Hi Luca,

The last two lines are what is hiding the prices on the cart/checkout. Remove those 2 and it should re-appear.


Luca August 22, 2018 at 12:35 pm

Hi Jeroen,

thanks for your reply.
I know that the last two lines hiding all prices on the cart/checkout, but I should still hide only the prices of the specifics category (“medici” and “dentisti”) in the cart/checkout.
Is there a solution for this?
Otherwise I would need a snippet code to hide priceson the cart/checkout page when that are 0.

Thanks in advance.

Jeroen Sormani August 23, 2018 at 11:07 am

I don’t have a ready to go code snippet that will hide those prices only for those categories. You’d have to further customize these snippets to fit your exact requirements.

John August 30, 2018 at 2:46 pm

I have an amazon affiliate store using the theme storefront by WooCommerce. My products were direct imported via Wzone. Apparently the product prices and availability being displayed on my site place in non-compliance with Amazon’s affiliate policies. I have several product categories that all show pricing and availability. This would not be an issue if these things were synced using Amazon’s PA API however they won’t allow access until you are fully accepted. What would be the best method to remove pricing/availability being displayed?

George September 6, 2018 at 4:30 am

How about removing the price from related products?

Jeroen Sormani September 6, 2018 at 10:09 am

If you use the first code snippet it should remove the prices from related products too – any product price really..

John September 6, 2018 at 3:41 pm

function so_38057349_woocommerce_cart_subtotal( $cart_subtotal, $compound, $cart ) {
if( $cart->subtotal == 0 ){
$cart_subtotal = __( ”, ‘yourtheme’ );
return $cart_subtotal;
add_filter( ‘woocommerce_cart_subtotal’, ‘so_38057349_woocommerce_cart_subtotal’, 10, 3 );

// define the woocommerce_order_amount_total callback
function so_38057349_woocommerce_order_amount_total( $order_total ) {
if( WC()->cart->get_total() == 0 ){
$order_total = __( ‘Procede to checkout to see your total’, ‘yourtheme’ );
return $order_total;
add_filter( ‘woocommerce_cart_totals_order_total_html’, ‘so_38057349_woocommerce_order_amount_total’ );
add_filter( ‘woocommerce_cart_item_price’, ‘__return_false’ );
add_filter( ‘woocommerce_cart_item_subtotal’, ‘__return_false’ );

This is the code that i’m currently using. I had to manually change the prices to zero in in order for it call for the array $order_total. That way it would return “Proceed to checkout to see your total.” I’m no coder by any means but this seems like a wonky method. Not sure if I could simply change the comparison operator to “>” instead of “==”. That way any number greater than 0 should return the same array.

As of right now, things seem ok other than my Cart still displays the Sub Totals price. I’m having a hard time getting that filtered out.

John September 6, 2018 at 3:48 pm

Update: changing the comparison operator to “!==” did the trick and removed the subtotal price altogether. I’m still not sure if this is a correct fix or some jumble that seemingly worked.

My last issue still unresolved is when you click on one of my products you will see “Item availability”. This is against Amazon’s terms when not using their API. I need to remove this before I get the boot from the affiliate program.

Ryan Grieco September 7, 2018 at 7:54 pm

Hi Jeroen,

Thank you for the helpful tips. Is there a way to hide a price on a specific product variation? For example, I have a variable product where one size has a price and the other cannot have one.

Jeroen Sormani September 13, 2018 at 9:23 am

Should be possible – though I haven’t tested it myself. I’d recommend starting with testing out the last code snippet and use a variation ID instead of the product ID. With a bit of luck that will work straight away.

If that doesn’t work you’d likely want to look into filters specifically for variation product prices.

Vale September 12, 2018 at 11:48 pm

Helped me a lot!
Thank you

Ben September 18, 2018 at 12:18 am

I like the snippet for hiding the price from guests, is there any way to hide the add to cart button and replace the prices with “login to view prices” text as well? Every other snippet I’ve found that does all of that doesn’t hide the price from the search bar but yours does.

Jeroen Sormani October 11, 2018 at 9:05 pm

Hi Ben,

You should be able to do this by entering the text within the `return ‘YOUR TEXT’;` instead of returning a empty string.


Ben October 11, 2018 at 4:58 pm

Hi Jeroen,

First of all thanks for your blogs. They are great!

quick question; would your little script: “Hiding prices in specific categories” also work when I have a product already in another category?

So for example the product is already in a category called “electronics” and I create a new category called “hide price”

will it hide the price of that product if I include the “hide price” category in your script?

Jeroen Sormani October 11, 2018 at 9:03 pm

Hi Ben,

Yes, this should work right out of the box with the script.


JUAN FURLAN October 17, 2018 at 10:57 am

Thanks a lot.

Jeraldine November 15, 2018 at 4:22 pm

Thanks Jeroen!

I’m interested about your snipet Hide price for a specific product but unfortunatly it doesn’t work for me 🙁
My product give the price “From… to…” given from Measurment price calculator woo plugin.
Is there a simple hook to achieved this?

Jeroen Sormani November 16, 2018 at 10:07 am

You could try it with a higher priority, but if that doesn’t work it’d require some other code to deactivate that plugin’s price output.

Leave a Reply