How to Remove Has Been Added to Your Cart Message WooCommerce

Remove Has Been Added to Your Cart Message WooCommerceIf you are looking for the quickest way to remove has been added to your cart message from your cart or checkout page in WooCommerce, I have a quick code snippet that I have tested and it works. You just need to drop this line of code in your functions.php file and it will do the trick

Remove Has Been Added to Your Cart Message WooCommerce

When a product is added to cart in WooCommerce this message appears at the top of the checkout page ‘ product has been added to your cart’.

This may be a necessary notification but sometimes you should remove this message from the checkout page. To remove this message open your functions.php file and add the code snippet below :

add_filter( 'wc_add_to_cart_message_html', '__return_false' );

This code removes all these notices that are printed on the cart and the checkout page.

Customize Has Been Added to Your Cart Message

If you would like to have your custom message instead of this default WooCommerce message and instead of removing it, you can use the same filter hook to customize the output.

You should create a filter with a callback function that filters this message and outputs your customized message.

For example, if we want to display the following message: ‘You cool product is in the cart !‘, we can use the following code snippet:

/**
 *  Custom Added to your Cart Message 
 */
 
add_filter( 'wc_add_to_cart_message_html', 'njengah_custom_added_to_cart_message' );
 
function njengah_custom_added_to_cart_message() {
	
	$message = 'You cool product is in the cart!' ;
	
	return $message;
	
}

As you can see from the code above we are using the same filter hook but in the callback function we are adding a custom message in the return.

Comments are closed.