How to Disable WooCommerce Blocks Safely
WooCommerce ships “Blocks” (Cart, Checkout, Product Grid, Mini Cart, etc.) via the WooCommerce Blocks package.
If your site uses classic shortcodes/templates (or you want a stricter editor experience), you may want to disable
WooCommerce blocks—without breaking existing pages or admin screens.
This guide shows safe, code-based approaches:
- Hide WooCommerce blocks from the editor inserter (low risk)
- Unregister WooCommerce block types (medium risk)
- Disable block-based Cart/Checkout features (only if you don’t use them)
- Avoid breaking pages that already contain WooCommerce block markup
Important: Know What “Disabling WooCommerce Blocks” Means
There are two separate goals people often mix up:
- Editor control: prevent editors from inserting WooCommerce blocks (recommended first step)
- Runtime removal: unregister blocks / stop assets (can break existing block pages)
Start with editor control. Only unregister blocks if you’re sure your site does not use them.
Option 1: Hide WooCommerce Blocks in the Block Inserter (Safest)
This keeps blocks registered (so existing content still renders), but prevents users from adding them.
It’s the best “safety-first” approach for large or multi-author sites.
<?php
/**
* Hide WooCommerce blocks from the inserter while keeping them functional for existing content.
* Put this in an MU plugin for reliability.
*/
add_filter( 'allowed_block_types_all', function ( $allowed, $editor_context ) {
// Only restrict in the post editor
if ( empty( $editor_context->post ) ) return $allowed;
// Allow everything else if core returns true by default
if ( $allowed === true ) {
// Fetch all currently registered blocks
$registry = WP_Block_Type_Registry::get_instance();
$all = array_keys( $registry->get_all_registered() );
// Remove WooCommerce blocks (namespace: woocommerce/*)
$filtered = array();
foreach ( $all as $name ) {
if ( strpos( $name, 'woocommerce/' ) === 0 ) continue;
$filtered[] = $name;
}
return $filtered;
}
// If a theme/plugin already returns a list, filter it
if ( is_array( $allowed ) ) {
return array_values( array_filter( $allowed, function ( $name ) {
return strpos( $name, 'woocommerce/' ) !== 0;
} ) );
}
return $allowed;
}, 100, 2 );
Result: existing WooCommerce blocks still render, but editors can’t insert new WooCommerce blocks.
Option 2: Unregister WooCommerce Blocks at Runtime (Use With Caution)
Unregistering removes the block definitions. If a page already contains those blocks, WordPress will treat them as
unknown blocks (best case) or render incomplete markup (worst case, especially for Cart/Checkout).
Only do this if:
- You do not use block-based Cart/Checkout pages
- You do not use Product Collection / Product Grid blocks in content
- You’ve audited content for WooCommerce blocks (search for
<!-- wp:woocommerce/)
Unregister All WooCommerce Blocks
<?php
/**
* Unregister all WooCommerce blocks.
* Medium/high risk if your content contains WooCommerce blocks.
*/
add_action( 'init', function () {
if ( is_admin() ) return;
if ( ! class_exists( 'WP_Block_Type_Registry' ) ) return;
$registry = WP_Block_Type_Registry::get_instance();
$blocks = $registry->get_all_registered();
foreach ( $blocks as $name => $block_type ) {
if ( strpos( $name, 'woocommerce/' ) === 0 ) {
unregister_block_type( $name );
}
}
}, 100 );
Prefer a Block Allowlist (Disable Only the Ones You Don’t Want)
A more controlled approach is to unregister specific block names. Example (names vary by WooCommerce version):
<?php
add_action( 'init', function () {
if ( is_admin() ) return;
$to_remove = array(
'woocommerce/cart',
'woocommerce/checkout',
'woocommerce/mini-cart',
'woocommerce/product-collection',
'woocommerce/featured-product',
'woocommerce/handpicked-products',
'woocommerce/product-best-sellers',
'woocommerce/product-new',
'woocommerce/product-on-sale',
'woocommerce/product-top-rated',
'woocommerce/products-by-attribute',
'woocommerce/products-by-category',
'woocommerce/products-by-tag',
);
foreach ( $to_remove as $name ) {
if ( function_exists( 'unregister_block_type' ) ) {
unregister_block_type( $name );
}
}
}, 100 );
If some of these block names don’t exist on your setup, that’s fine—the unregister call will no-op.
Option 3: Prevent Breaking Existing Content (Guarded Unregister)
If you want to unregister blocks but avoid breaking pages that already use them,
you can “guard” the removal by checking whether the current post content contains WooCommerce blocks.
This keeps compatibility for legacy pages while blocking new usage elsewhere.
<?php
/**
* Unregister WooCommerce blocks only when the current request is NOT rendering a post that contains them.
* Works best for singular content. Archives/search results may still require broader handling.
*/
add_action( 'wp', function () {
if ( is_admin() ) return;
if ( ! is_singular() ) return;
$post = get_queried_object();
if ( ! ( $post instanceof WP_Post ) ) return;
// If the content already uses WooCommerce blocks, keep them registered.
if ( has_block( 'woocommerce/cart', $post ) || has_block( 'woocommerce/checkout', $post ) ) {
return;
}
// Remove all WooCommerce blocks (or a specific list)
$registry = WP_Block_Type_Registry::get_instance();
foreach ( array_keys( $registry->get_all_registered() ) as $name ) {
if ( strpos( $name, 'woocommerce/' ) === 0 ) {
unregister_block_type( $name );
}
}
}, 50 );
This is not perfect (archives can still show excerpts that include blocks), but it’s much safer than a global unregister.
Option 4: Disable Block-Based Cart/Checkout Features (Only If You Use Classic Templates)
WooCommerce can provide block-based Cart and Checkout experiences.
If your site uses classic pages/templates and you want to enforce that, you should ensure
your Cart/Checkout pages are not block-driven.
The safest operational approach is:
- Use WooCommerce shortcodes or classic templates for Cart/Checkout
- Do not use the Cart/Checkout blocks on those pages
If you are already on classic Cart/Checkout, the “Hide in inserter” approach is often enough.
Recommended Strategy (Most Sites)
- Start with Option 1 (hide WooCommerce blocks in the editor)
- Audit content for existing WooCommerce blocks
- If none are used, consider Option 2 (unregister specific blocks)
- If some are used, apply Option 3 (guarded unregister) or keep blocks registered
Quick Audit Tip (Find WooCommerce Blocks in Content)
WooCommerce blocks appear in post content as block comments like:
<!-- wp:woocommerce/cart -->
If you have database access, search post_content for:
<!-- wp:woocommerce/
If you find matches, do not globally unregister those blocks unless you plan to migrate those pages.
Summary
- Safest: hide WooCommerce blocks in the editor inserter
- Risky: unregister block types globally (can break existing pages)
- Safer unregister: guard removal when current content uses WooCommerce blocks
- Always audit Cart/Checkout pages before disabling block-based components
If you tell me whether your Cart/Checkout pages are built with blocks or classic shortcodes/templates,
I can give you a minimal configuration that blocks new usage without risking existing conversions.
🎨 Want to learn more? Visit our WordPress Customization Hub for tips and advanced techniques.