You can conditionally hide a widget in WooCommerce on specific pages, like the cart or checkout, by filtering the active sidebar widgets and removing a specific widget ID whenever a WooCommerce conditional tag matches.
Why Hide a Widget on Certain Pages
- Some widgets (like a product carousel) don’t make sense on pages where a purchase is already underway
- Reduces distraction on the cart or checkout page specifically, where focus matters most
- Avoids installing a full widget-visibility plugin for a single, simple rule
- Extendable to any WooCommerce conditional tag (product page, category page, etc.)
Step 1: Find Your Sidebar and Widget IDs
In your browser’s inspector, right-click the sidebar and the specific widget to find their DOM IDs — you’ll need both exact IDs for the snippet to target the right widget.
Step 2: Remove the Widget Conditionally
/** Hide a specific sidebar widget on the WooCommerce Cart page only */
add_filter( 'sidebars_widgets', 'hide_widget_on_cart_page' );
function hide_widget_on_cart_page( $active_widgets ) {
if ( is_admin() ) {
return $active_widgets;
}
if ( is_cart() ) {
$widget_key = array_search( 'woocommerce_products-3', $active_widgets['sidebar-primary'] );
if ( false !== $widget_key ) {
unset( $active_widgets['sidebar-primary'][ $widget_key ] );
}
}
return $active_widgets;
}Troubleshooting
Widget still shows after adding the snippet
Double-check the exact sidebar ID and widget ID — a small mismatch (like sidebar-1 vs sidebar-primary) means array_search() silently finds nothing to remove.
Want to hide a widget on multiple page types
Combine conditions with ||, e.g. if ( is_cart() || is_checkout() ), to apply the same removal across several WooCommerce page types at once.
Frequently Asked Questions
Does this permanently remove the widget from the sidebar?
No, it only removes it from the active widgets array for the specific conditional match — the widget remains fully configured and shows normally on every other page.
Can I use any WooCommerce conditional tag here?
Yes, any function like is_product(), is_shop(), or is_product_category() works the same way inside the condition.
Is there a plugin alternative if I need this for many widgets?
Yes, a dedicated widget-visibility plugin makes more sense once you’re managing conditional logic across many widgets rather than one or two — this snippet is best for simple, isolated cases.
Conclusion
A single filter is enough to conditionally hide a widget in WooCommerce for a specific page without a dedicated plugin. Confirm your exact sidebar and widget IDs first, since a small typo there is the most common reason this doesn’t work on the first try.
See also How to Hide Categories From the Product Categories Widget in WooCommerce. Then read How to Display Different Widgets Based on Product Category in WooCommerce.
Prefer no code? All-in-One Utilities Woo Add-on adds over 50 WooCommerce features, so you can switch them on without code.