In WooCommerce, you have the flexibility to remove or customize the ‘Added to Your Cart’ message displayed when a product is added to the cart. With a few lines of code added to your theme’s functions.php file, you can completely eliminate this message or tailor it to better suit your website’s unique needs and branding.
Let’s explore both methods for applying these codes.
Method 1: Completely Remove the Message
To completely remove the “Added to Your Cart” message, you can add the following code to your theme’s functions.php file:
/**
* @snippet To Remove "added to your cart" message"
* @author Cool Plugins
* @compatible WooCommerce 5
*/
add_filter( 'wc_add_to_cart_message_html', '__return_null' );
Method 2: Customize the Message
If you want to edit the message rather than remove it entirely, you can use the following code to change the message to something else:
/**
* @snippet To Remove "added to your cart" message"
* @author Cool Plugins
* @compatible WooCommerce 5
*/
add_filter( 'wc_add_to_cart_message_html', 'cool_change_add_to_cart_message' );
function cool_change_add_to_cart_message() {
$cart_message = 'Great choice!' ;
return $cart_message;
}