Remove “Product removed. Undo” notice from WooCommerce

Shop "Come in We are open" sign

In this blog post, we will teach you how to remove the “Product removed. Undo” notice from your WooCommerce pages.

Undo product remove notice

You may not want to show this notification to your visitors. Unfortunately, there’s no setting that can get rid of this notice. Instead, we can use a code snippet. Add the snippet below to your site. Not sure how to do that? Read here how to safely add code snippets.

function sw_delete_remove_product_notice(){
	$notices = WC()->session->get( 'wc_notices', array() );
		for($i = 0; $i < count($notices['success']); $i++){
			if (strpos($notices['success'][$i], __('removed','woocommerce')) !== false) {
		WC()->session->set( 'wc_notices', $notices['success'] );

add_action( 'woocommerce_before_shop_loop', 'sw_delete_remove_product_notice', 5 );

All this does is lookup the current ‘success’ notices and delete the notice with ‘removed’ in the sentence. With that in mind, it’s not failsafe but should do the trick as it’s unlikely that there will be 2 different success-notices with the word ‘removed’ in them.

The code above only removed the notice from the Shop page. If you want to remove it on single product pages or category pages, you can add these 2 lines of code as well:

add_action( 'woocommerce_shortcode_before_product_cat_loop', 'sw_delete_remove_product_notice', 5 );
add_action( 'woocommerce_before_single_product', 'sw_delete_remove_product_notice', 5 );

That’s how easy it is to remove the “Product removed. Undo” notice from WooCommerce!