Make Products Non-Purchasable

When you would like to turn your WooCommerce shop into a catalog for example, there could be different options how to do it. Or maybe you would like to make non-purchasable just some specific products – I don’t know, but I hope this tutorial will cover everything.

In the first chapter I will show how you can do it just in your WooCommerce admin, but then we will dive deep into using woocommerce_is_purchasable filter hook and then play with some conditions.

It is worth mentioning that the ways described here are the most correct ones, because, if let’s say, you just removed “Add to Cart” button (I hope not with CSS at least), the products will still be available for purchase in some way.

If at the moment of integrating these methods into a website, customers have any of the non-purchasable products in their carts, the products will be immediately removed.

Okay, let’s do something.

The easiest way to prevent a product from being purchased is to remove its price. Not to set it to 0, but to empty the price field completely, like this:

how to remove product price completely

Once you do that, your product will be displayed like this, completely unavailable for purchase.

WooCommerce products without price are not purchasable

Another option is to go to Inventory tab and set the product stock status to “Out of stock” or stock quantity to 0.

WooCommerce product stock management

Ok, as I already mentioned before, it works great on a per product basis, but what if you would like to turn your WooCommerce store into a catalog and completely disable purchasing any product?

woocommerce_is_purchasable

As simple as to insert the below code into your functions.php file, you can completely disable purchasing all the products on your WooCommerce website.

/**
 * Make all WooCommerce products non-purchasable
 * 
 * @author Misha Rudrastyh
 * @url https://rudrastyh.com/woocommerce/make-products-non-purchasable.html#woocommerce_is_purchasable
 */
add_filter( 'woocommerce_is_purchasable', 'misha_catalog_mode_on' );
function misha_catalog_mode_on( $is_purchasable ) {
	
	$is_purchasable = false;
	return $is_purchasable;
	
}

Actually this filter hook can be written just in a single line of code, but I wanted to keep things clear for you. So, here is how:

add_filter( 'woocommerce_is_purchasable', '__return_false' );

The next thing I want to show you is how you can use woocommerce_is_purchasable filter hook for products in specific product categories or even for products with certain IDs. Ok, let’s play with some conditions now.

For specific product IDs

/**
 * Make specific WooCommerce products non-purchasable
 * 
 * @author Misha Rudrastyh
 * @url https://rudrastyh.com/woocommerce/make-products-non-purchasable.html#specific-products
 */
add_filter( 'woocommerce_is_purchasable', 'misha_catalog_mode_on_for_product', 10, 2 );
function misha_catalog_mode_on_for_product( $is_purchasable, $product ) {
	
	$not_purchasable_products = array( 123, 45, 789 );
	
	if( in_array( $product->get_id(), $not_purchasable_products ) ) {
		$is_purchasable = false;
	}
	return $is_purchasable;
		
}

You can pass as many product IDs as you want in $not_purchasable_products variable.

For specific product categories or product tags

/*
 * Disable buying products from specific category and tag
 *
 * @author Misha Rudrastyh
 * @url https://rudrastyh.com/woocommerce/make-products-non-purchasable.html#specific-categories
 */
add_filter( 'woocommerce_is_purchasable', 'misha_catalog_mode_on_for_category', 10, 2 );
function misha_catalog_mode_on_for_category( $is_purchasable, $product ) {
	
	// First – check product categories
	if( has_term( 'uncategorized', 'product_cat', $product->get_id() ) ) {
		$is_purchasable = false;
	}
	// Second – check product tags
	if( has_term( 'newyearsale', 'product_tag', $product->get_id() ) ) {
		$is_purchasable = false;
	}
	
	return $is_purchasable;
}

You can find more examples of has_term() usage in this tutorial.

Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X