Spoiler alert – we are going to do that without plugins! 😁🎉

Turning off WooCommerce Gutenberg Blocks in Block Manager

I already talked about in here, actually you do not have to force disable Gutenberg blocks in your code. Anyway, before doing it, please consider turning off blocks in Block Manager which appeared in WordPress 5.2

WooCommerce blocks are also presented there:

Using Block Manager to turn off WooCommerce Gutenberg blocks
You can access Block Manager from the menu in the top right part of the screen.

Force Disable WooCommerce Gutenberg Blocks in the Code

At the moment of writing this tutorial WooCommerce do not have a filter hook to prevent some of the blocks from being registered, so I am going to show you how to do it with the help of allowed_block_types filter hook.

There is a whole tutorial about this filter hook on my website.

Anyway, it is not difficult for me to explain one more time how allowed_block_types works.

  • By default this filter hook returns true, which means that all the blocks are allowed by default.
  • If you pass into this filter hook an array of block names, like [ 'core/image', 'core/paragraph' ] – only these particular blocks will be allowed in Gutenberg.
  • You can use WP_Block_Type_Registry::get_instance()->get_all_registered() to get all the blocks registered by plugins, which can help you. I will show you below, how.

Example 1

The easy one, let’s suppose that’ve inserted this code into your (child) theme functions.php file:

add_filter( 'allowed_block_types', 'misha_allow_2_woo_blocks' );
function misha_allow_2_woo_blocks( $allowed_blocks ){
	$allowed_blocks = array(
	return $allowed_blocks;

And the result:

Allow only 2 WooCommerce Gutenberg blocks with allowed_block_types filter hook

That’s too much, right? 😁

Example 2

As you probably understood from our previous example, when you’re using allowed_block_types, you have two options:

  • Either specify all the possible block you would use in your code…
  • … or to get the blocks in the code somehow.

WP_Block_Type_Registry::get_instance()->get_all_registered() will help us with it. This is how:

add_filter( 'allowed_block_types', 'misha_allowed_blocks' );
function misha_allowed_blocks( $allowed_blocks ) {
	$registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
 	// specify all the blocks you would like to disable here
	unset( $registered_blocks[ 'woocommerce/all-products' ] );
	unset( $registered_blocks[ 'woocommerce/all-reviews' ] );
	// etc ...
	// now $registered_blocks contains only blocks registered by plugins, but we need keys only
	$registered_blocks = array_keys( $registered_blocks );
	// merge the whitelist with plugins blocks
	$allowed_blocks = array_merge( 
	return $allowed_blocks;

Please let me explain that a little bit:

  • Line 3. Variable $allowed_blocks is equal 1 at the beginning unless allowed_block_types is not hooked somewhere else.
  • Line 5. This method allows us to get the objects as an associative array of all the blocks registered by plugins, and widget blocks by the way. So $registered_blocks will contain all the WooCommerce blocks as well. But this method doesn’t return default Gutenberg blocks like paragraph, list etc.
  • Lines 8-9. As $registered_blocks is an associative array, we can easily remove a block element from there if we know its slug. All the WooCommerce block slugs are listed below.
  • Line 13. We don’t need objects, just block names (slugs).
  • Lines 17-22. Unfrotunately we have to pass default block names manually. The full list of default block names (slugs) is here.

List of WooCommerce Gutenberg Block Names / Slugs

  • woocommerce/all-reviews – All Reviews,
  • woocommerce/featured-category – Featured Category,
  • woocommerce/featured-product – Featured Product,
  • woocommerce/handpicked-products – Hand-picked Products,
  • woocommerce/product-best-sellers – Best Selling Products
  • woocommerce/product-categories – Product Categories List
  • woocommerce/product-category – Products by Category
  • woocommerce/product-new – Newest Products
  • woocommerce/product-on-sale – On Sale Products
  • woocommerce/products-by-attribute – Products by Attribute
  • woocommerce/product-top-rated – Top Rated Products
  • woocommerce/reviews-by-product – Reviews by Product
  • woocommerce/reviews-by-category – Reviews by Category
  • woocommerce/product-search – Product Search
  • woocommerce/product-tag – Products by Tag
  • woocommerce/all-products – All Products
  • woocommerce/price-filter – Filter Products by Price
  • woocommerce/attribute-filter – Filter Products by Attribute
  • woocommerce/active-filters – Active Product Filters

And here is the list of default Gutenberg block names/slugs.


Leave a Reply