14

I want to remove the "xx product has been added to your cart" message from the top of my checkout page.

How can I do that?

There was a suggestion by someone (link below), but it didn't work for me.

Remove/Hide Woocommerce Added to Cart Message but Keep/Display Coupon Applied Message

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Mary
  • 209
  • 1
  • 5
  • 12

2 Answers2

29

Update for Woocommerce 3+

The hook wc_add_to_cart_message is deprecated and replaced by wc_add_to_cart_message_html. You can use the following (compact effective way):

add_filter( 'wc_add_to_cart_message_html', '__return_false' );

Or the normal way:

add_filter( 'wc_add_to_cart_message_html', 'empty_wc_add_to_cart_message');
function empty_wc_add_to_cart_message( $message, $products ) { 
    return ''; 
}; 

Before Woocommerce 3, use this:

Removing only the message (pasting it to your function.php file inside your active child theme or theme). This function will return an empty message:

add_filter( 'wc_add_to_cart_message', 'empty_wc_add_to_cart_message', 10, 2 );
function empty_wc_add_to_cart_message( $message, $product_id ) { 
    return ''; 
}; 

Code goes in function.php file of your active child theme (or active theme).

Note: wc_add_to_cart_message replace deprecated hook woocommerce_add_to_cart_message.

(UPDATED)

CSS: Removing top message box on checkout page (add this css rule to the style.css file located inside your active child theme or theme):

.woocommerce-checkout .woocommerce .woocommerce-message {
    display:none !important;
}
LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • Thanks for your help. This deleted the message & the button that said Continue Shopping, but it leaves an empty grey box at the top of the page. Is there a way to remove that? – Mary May 10 '16 at 15:51
  • I tried suggestion #2. The first one didn't work for me. The site link is https://sprinly.com/subscription-plan, then you click any of the sign up buttons, then go to https://sprinly.com/checkout. You will see the box at the top. Thanks you in advance!! – Mary May 10 '16 at 19:57
  • This worked great for me. I no longer see the grey box or the message. Thank you! – Mary May 10 '16 at 21:20
  • You may not need the function, but just the css rule… Thanks Mary. – LoicTheAztec May 10 '16 at 22:16
  • Didn't work for me. Added CSS code but not PHP code (I have only `functions.php`). – c0dehunter Nov 04 '16 at 17:22
  • @Primož'c0dehunter'Kralj The php code goes in function.php of your active child theme or active theme. – LoicTheAztec Nov 04 '16 at 19:27
  • Where do I find this file? I can't find it under [current theme directory](http://imgur.com/a/PiV59). – c0dehunter Nov 04 '16 at 20:15
  • @Primož'c0dehunter'Kralj It's inside your "optimizer" theme folder normally. Each theme has a function.php file (inside). Is better to set a child theme, because you don't loose your customizations when you update the parent theme… see [wordpress child theme](https://codex.wordpress.org/Child_Themes) for that. – LoicTheAztec Nov 05 '16 at 00:41
  • wc_add_to_cart_message is deprecated, use wc_add_to_cart_message_html instead. – Kaizoku Gambare Jun 21 '18 at 09:50
1

You have to use this code in order to hide this

add_filter( 'wc_add_to_cart_message_html', '__return_false' );

You can find more information here hide added to your cart