WooCommerce: Remove / Edit “Added to Your Cart” Message

A client asked me to completely remove the message that appears after you add a product to the cart from the product page. This is simply done by using a PHP snippet, so here’s the quick fix for you!

How to remove the “Added to your Cart” message in WooCommerce

PHP Snippet #1: REMOVE “X has been added to your cart” Message

 * @snippet       Remove "added to your cart" message
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=494
 * @author        Rodolfo Melogli
 * @compatible    WC 3.5.4
 * @donate $9     https://businessbloomer.com/bloomer-armada/

add_filter( 'wc_add_to_cart_message_html', '__return_null' );

PHP Snippet #2: EDIT “has been added to your cart” Message

 * @snippet       Edit "has been added to your cart" message
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=494
 * @author        Rodolfo Melogli
 * @compatible    WC 3.5.4
 * @donate $9     https://businessbloomer.com/bloomer-armada/

add_filter( 'wc_add_to_cart_message_html', 'bbloomer_custom_add_to_cart_message' );

function bbloomer_custom_add_to_cart_message() {
$message = 'Nicely done!' ;
return $message;

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials. You can start learning how to customize WooCommerce without unnecessary plugins. Watch me code and learn by example!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

104 thoughts on “WooCommerce: Remove / Edit “Added to Your Cart” Message

  1. Hey Rodolfo,

    I have a request if you can do that for me, please.
    I want to add a checkout link to this entire message, which I get when I click the “Add to Cart” button.

    Example text – β€œProduct” has been added to your cart.

    Thanks much!

    1. Hi Sumit, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. This snippet produces warnings in the checkout page with the latest Woocommerce update (3.9.0). I fixed it by returning an empty string instead of null as in the code below:

    function filter_wc_add_to_cart_message_html( $message, $products ) {
    return '';
    // add the filter
    add_filter( 'wc_add_to_cart_message_html', 'filter_wc_add_to_cart_message_html', 10, 2 );

    not sure if this is the right way to fix it, but it works for me.

    1. Thank you

    2. Does this corrected code work?

      1. Maybe there was a problem with “curly quotes”. Try again now, I’ve revised it for you

  3. Thanks for this code.
    I don’t understand much in php but I am trying to reposition the line under the “add to cart” button with no success.
    Hope you can help πŸ™‚

    1. Screenshot?

  4. There are lots of comments about “Add to Cart” messages, but I can’t find a single item about the “Would you like more goods?” message found in the woocommerce-cart-form in a woocommerce-message wrapper. I’ve not found any way to hook and delete this item. Do you have a suggestion?

    1. Hey Jim, thanks for your comment! That’s not default, so it’s probably a different plugin πŸ™‚

  5. I made a search and came across this site: https://stackoverflow.com/questions/25880460/woocommerce-how-to-edit-the-added-to-cart-message

    It adds the name of the product and two buttons on the right side: Show Cart and go to Checkout.

    add_filter ( 'wc_add_to_cart_message', 'wc_add_to_cart_message_filter', 10, 2 );
    function wc_add_to_cart_message_filter($message, $product_id = null) {
    $titles[] = get_the_title( $product_id );
    $titles = array_filter( $titles );
    $added_text = sprintf( _n( '%s has been added to your cart.', '%s have been added to your cart.', sizeof( $titles ), 'woocommerce' ), wc_format_list_of_items( $titles ) );
    $message = sprintf( '%s <a href="%s" class="button">%s</a>&nbsp;<a href="%s" class="button">%s</a>',
                    esc_html( $added_text ),
                    esc_url( wc_get_page_permalink( 'checkout' ) ),
                    esc_html__( 'Checkout', 'woocommerce' ),
                    esc_url( wc_get_page_permalink( 'cart' ) ),
                    esc_html__( 'View Cart', 'woocommerce' ));
    return $message;}
    1. Cool, thanks a million Paal πŸ™‚

  6. Could you help me how to change the text of Add to Cart button to view cart after clicking?

    1. Azimi, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  7. How to add “product added to cart” in home page?
    When I click on “Buy” nothing appears.

  8. Can the name of the product be added to the message – “xxxxxx successfully added to your cart.”?

    1. Hey Rob, thanks for your comment! Yes, good question – you’ll need to get the product name by declaring the global $product and then with this: https://businessbloomer.com/woocommerce-easily-get-product-info-title-sku-desc-product-object/. Hope this helps!

  9. Hi! I have succesfully added this: add_filter( ‘wc_add_to_cart_message_html’, ‘__return_null’ ); to my functions.php I am NOT a developer at all, sp pretty happy. BUT, all my products can only be added once, and this message is still shown. I like to remove ALL the messages in the top. Can you please help me? Thanks a lot!

    1. Sessan, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  10. Hello!

    How do you change the colour of that message? example replace the green line and tick to black?

    1. Anita, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  11. Hi, is there a way to just show all the woocommerce messages for a defined time?


    1. Hey Gulshan, thanks for your comment! If I understand well, it’s not possible to do that via PHP. You will need Ajax.

  12. Hi Rodolfoo,
    After putting your snippet add_filter( ‘wc_add_to_cart_message_html’, ‘__return_null()’ );
    I’m getting this message :
    “Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘false’ not found or invalid function name in F:\xampp\htdocs\odpbb\wp-includes\class-wp-hook.php on line 300”

    This message disappear when I’m checking “Enable AJAX add to cart buttons on archives”
    BUT when I’m trying to redirect addtocart directly to the checkout page with the url “checkout/?add-to-cart=65” or your “bbloomer_redirect_checkout_add_cart” snippet, I get again the error message…

    Any hint?

    ps : Thanks a lot for all information you provide us!!

    1. sorry bad copy, the error msg is “Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘__return_null()’ not found or invalid function name in F:\xampp\htdocs\odpbb\wp-includes\class-wp-hook.php on line 300”

      I’m running the woocommerce 3.1.1 and wordpress 4.8.1

      1. David, thanks for your comment! Weird, but also correct – I just revised the snippet, “__return_null” should not have “()”. Let me know if it works πŸ™‚

  13. Hi Rodolfo,

    I was trying to add both view cart and continue shopping in the same area. Is it possible?


    1. Hey Anuj, thanks for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  14. So this is to remove it, but how do you edit it? i.e. remove the buttons in the notice?

    1. Hey Kevin, thanks for your comment! You will need to work within Snippet #2 inside the $message variable – do some HTML changes in there πŸ™‚

    2. Thanks so much! Pretty obvious answer, must’ve had some tunnel vision lol

  15. Hi,

    First of all , excellent blog, I learned a lot ( first time dealing with php ).
    I am trying to change a massage You cart is empty, can u help me with this. Also what you are suggesting for translating some words like “cash on delivery”, “Place order”, “Billing”

    Best regards,

  16. Hi Rodolfo,

    Instead of editing the message, is there a way to just hide the message? I’m on WC 3.0+

    1. Yes Tony, I just added a new snippet – let me know if it works πŸ™‚

  17. Hey!

    I use the same code, but I’m getting an error on the latest WC update saying to use


    instead… anyone else getting this error?

    Can’t seem to find any examples online – tried just appending the _html but didn’t work! I’m just getting used to using these filters, so any help would be much appreciated.


    1. Hey Dan, thanks for your comment! I just revised the snippet and it works just by changing the name of the filter πŸ™‚

  18. Hello! For code snippet2, what do you do if you want to edit the “successfully added to cart” message for an entire category? Or multiple product ID’s? Thank you

  19. MERCI !! Thanks a lot !

    1. You’re welcome Lucien!

  20. hey first of all great job,
    i am trying to print message out after the payment id done

    add_action( 'woocommerce_payment_complete', 'so_payment_complete' );
    function so_payment_complete( $order_id ){
        $order = wc_get_order( $order_id );
        $bng_order = unserialize(get_post_meta($order_id)[_wcuf_uploaded_files][0]);

    but i get nothing out

    1. Hey Mohamed, thanks for your comment! I believe you’re using the wrong hook – try with woocommerce_thankyou πŸ™‚

  21. Hi Rodolfo,
    many thanks for your interesting tutorials! I’ve succesfully used the CSS snippet in order to hide the message in the checkout page. But what if I would also like to hide the “Already added to the cart” warning?

    1. Hey Paolo, thanks for your message! Doesn’t that CSS hide ALL WooCommerce messages on the single product page already? Have you tested it?

  22. Hi Rodolfo,
    Thanx for explain.
    I want remove the bottom ”view card ” definitely
    Can you give me code to insert it on fuction.php ?

    1. Hey Youssef, thanks for your comment!

      Just use snippet #1, and change $message into:

      $message = ‘Your product was successfully added to cart’;

  23. Hi Rodolfo,

    Not sure if I am posting this in the right place! Hope you can share some insight on this.

    I have a page with different sections, and I have added the simple product “add to basket” shortcodes to buttons on this page:
    Buttons shortcodes look like this:
    [button title=”Add to basket” icon=”icon-basket” icon_position=”left” link=”http://lubiland.gg/register-gg-domain-name/?add-to-cart=263″ large=”0″ ]
    and they work, but redirect to the top of the page.

    Each section has an ID, and if I use the URL on its own, like this:
    it works, however what I am trying to achieve is to jump to the next section once something has been added to basket in the previous section.

    If I add this /#email to the end of the URL to the add to cart – the link doesn’t work… πŸ™

    [button title=”Add to basket” icon=”icon-basket” icon_position=”left” link=”http://lubiland.gg/register-gg-domain-name/#email/?add-to-cart=263″ large=”0″ ]

    Am I missing something?
    Thank you for any info you may provide.

    1. Hey Lubi, thanks for your comment! Yes, this is not the correct place to post it, but all I can say is to check this snippet: https://businessbloomer.com/woocommerce-redirect-checkout-add-cart/. You can change it slightly and decide where you want to redirect upon add to cart πŸ™‚ Hope this helps!

  24. Hi! Thanks for your tutorials. I’m a big fan.
    Can you add here the method to MOVE the “Product has been added to the cart” message where ever the user wants?

    For example, I wanted this message to be on top. What worked for me is adding this snippet on top of header.php:

    // remove "Product has been added to your cart" message
    remove_action( 'storefront_content_top', 'storefront_shop_messages' , 15);
    remove_action( 'woocommerce_before_single_product', 'wc_print_notices' , 10);
    // add the message back to your preferred hook
    add_action( 'storefront_before_header',  'wc_print_notices' );
    1. Thanks for your contribution Naveen, much appreciated!

  25. Very nice snippets, thanks! Learned a lot of them.
    Can you add snippet #4, that would be WCproduct loop page, when you click add to cart, you get view cart as well (ajax)
    How to change that one? Can’t figure it out.


    1. Hey Jake, thanks for your comment and sorry for the delay! I will see if I can add this one to the blog in the next few months, thank you πŸ™‚

    1. Thank you Colin! πŸ™‚

  26. Hi Rodolfo, thanks for this snippet. Is there a way to get the product title/id into the filter. So that we could echo the name of the product in the message? I am struggling to accomplish this.

    1. After a few hours of fresh air, I got back to the code and came up with this solution: https://gist.github.com/rastitkac/44050f8ef562c7dc9ac4a059e2579348
      I hope it’s ok with you, if I leave it hear for anyone who might search for a solution in the future.

      All the best, Rasti.

      1. Hey Rasti, thanks so much for following up and thanks a million for adding value to my blog πŸ™‚ Have a nice day!

      2. Wow!! You are my hero! This fits perfectly what I was looking for!

        With this piece of code I’m able to put the button on the right side!

        1. Thank you Ronald! πŸ™‚

  27. Hey Rodolfo, thank you. The code is just what I was looking for.

    However, I’m not using a “SHOP” page – can you tell me how I need to edit the code to redirect to a non-woocommerce page (where the link is “continue shopping” and redirects to shop.

    I need it to go to http://mydomain.com/specificpage

    Can I just change this line? $return_to = get_permalink(woocommerce_get_page_id(‘shop’)); and if so how do I do so


    1. Hello Mark, thanks a million for your comment! You can definitely use a custom URL – all you need is this:

      $return_to = 'http://my-custom-url.com';
      1. Rodolfo, you’re my new hero – Thank you so much. Works perfectly.

        1. You’re welcome Mark! Thanks for the “hero” – that’s a first time for me πŸ™‚

          1. I know this isn’t directly related to this post but I’m hoping you can point me to one of your tutorials or where I can find the answer to this:

            On the basket or maybe its called the cart page, there’s an area where the number of items can be changed, removed etc and a button with the text “Update Basket” I need to change that text to “Update Order” but I simply cannot find how I work out what the filter is called to do that. I’m sure you must have covered it somewhere already but I’m going crazy looking. Thanks in advance

            1. Hey Mark! Yes this is off topic but the good news is I wrote a tutorial about this: https://businessbloomer.com/translate-single-string-woocommerce-wordpress. Enjoy!

          2. I said you were my hero yesterday, Rodolfo, today you’ve become my “super hero”.

            Thanks so much for the link re Translate Strings – worked a treat.


            1. Ahah, thank you Mark πŸ™‚

    1. Adriano, thanks for your comment. I just tried this (note the ID and DATA-TARGET) and it works:

      // Edit "successfully added to your cart"
      add_filter( 'wc_add_to_cart_message', 'bbloomer_custom_add_to_cart_message' );
      function bbloomer_custom_add_to_cart_message() {
      global $woocommerce;
      $return_to  = get_permalink(woocommerce_get_page_id('shop'));
      $message    = sprintf('<a href="%s" id="aid" data-target="atarget" class="button wc-forwards">%s</a> %s', $return_to, __('Continue Shopping', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') );
      return $message;
  28. I want this message to be displayed for the limited fraction of time like 2 or 3 seconds. How can I do that?

    1. Hey Siddhartha, thanks for your comment! In this case, you will need JS or Ajax skills as they can allow you to hide something after a certain element has been loaded. I’m afraid I cannot provide support for this right now, but combining this snippet with a JS function should be pretty easy for a freelancer. Thank you!

  29. Hi there.

    Thanks for sharing =)

    I have a question, if you can help with I will be very grateful:

    I would like to disable the banner message only for a specific page — the homepage. How would I go about for doing this?


    1. Hey Rafael, thanks for your feedback πŸ™‚ If you want to execute the function on the homepage only, you can use the is_front_page() conditional tag:

      function bbloomer_custom_add_to_cart_message() {
      if ( is_front_page() ) {
      // original PHP here

      Hope this helps πŸ™‚

  30. Hi Rodolfo,

    i am also looking for a solution to “if a certain product has been added to the cart a unique message is displayed otherwise the default is fine”

    the snipped you have added above doesn’t work. like zach i also get and empty notice box.
    or even better would be to display an additional message below the wc_add_to_cart_message for one of my items.

    if a customer adds product 1200 to the cart he should get the following message displayed.

    “well done! pleas click here to select your coffee”

    1. Hey, thanks for your comment! I just edited the blog post and added “Snippet #2”, which will work for a specific Product ID. Test it out and let me know πŸ™‚ Cheers! ~R

  31. Hi I hope you can help me out.

    My client wants to use the check out a a request a quote so the “add to cart” will the request a quote and the cart message should be quote added click to view quote then you would go to he check out page and submit the quote not purchase the product.

    Please let me know if you could help me.

    1. Thanks for your query Louis. Have you tried already this codecanyon plugin? I think it does exactly what you need for a fair price. R

      1. Hi Rodolfo my client doesnt want to spend any money on the site he just wants it to work like he wants.

        I am currently running the Propoza plugin but it keeps sending me to there site to see the quote.

        1. I understand. Sorry but I can’t help you here, either way you’ll need to buy a plugin or pay a developer πŸ™‚ Thanks for your feedback!

          1. Thank you very much. And thank you for the resources on your site.

          2. One last question please.

            If I want to change the message to “Product was successfully added to your quote: which php file should I use?

            1. This is probably created by the “quote” plugin you’re using. You should take a look at its code, find where the message is generated and see if there is a similar filter you can use to edit this text. Hope this helps!

              1. Hi no its not the plugin its on the woocom. plugin as soon as you ad to cart on in my case click for a better price it gives me the woocom. message that it was added to the cart I just want it to say “product name” has been added & view cart should be view quote I know the code is in the woocom plugin but I dont know which file to get the line and change it.

                Can I perhaps send you a Private message?

                1. Louis, the second snippet in this page allows you to customise that message. Have you tried it yet?

                  1. Hi I managed to get the code where to change the copy.

                    Thank you very much

                    1. Excellent! Thank you πŸ™‚

  32. Hi, I just wantnto change the text, not hide it. Which plugin file has thecustom check out text in it?

    1. Hey Vanessa thanks for your feedback. If I’m not wrong the second snippet allows you to edit the text – otherwise you can find the function under woocommerce\includes\wc-cart-functions.php. R

  33. Hmm it’s not pasting correctly the $message is omitting the link code.

    1. Your snippet is different from mine πŸ™‚

      ….$message = sprintf(‘%s %s’….

  34. add_filter( ‘wc_add_to_cart_message’, ‘custom_add_to_cart_message’ );
    function custom_add_to_cart_message() {
    global $woocommerce;
    if ( is_single(60) ) { // conditional check for product id = 99
    $return_to = get_permalink(woocommerce_get_page_id(‘shop’));
    $message = sprintf(‘%s %s’, $return_to, __(‘Continue Shopping’, ‘woocommerce’), __(‘Product successfully added to your cart.’, ‘woocommerce’) );
    } // close conditional check for product id
    return $message;

  35. Hi Rodolfo,

    Thanks for posting this article. I’m not so good with PHP but am looking to modify your solution so that if a certain product has been added to the cart a unique message is displayed otherwise the default is fine. Any ideas how to add an if statement?

    1. Hey Zach, thanks for this. You can simply put a conditional check:

      add_filter( 'wc_add_to_cart_message', 'custom_add_to_cart_message' );
      function custom_add_to_cart_message() {
      global $woocommerce;
      if ( is_single(99) ) { // conditional check for product id = 99
      $return_to  = get_permalink(woocommerce_get_page_id('shop'));
      $message    = sprintf('<a href="%s" class="button wc-forwards">%s</a> %s', $return_to, __('Continue Shopping', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') );
      } // close conditional check for product id
      return $message;
      1. Thanks Rodolfo, I have tried a number of alternatives to this solution and this seems to be the closest one to working. However when I add this code and edit according to comments, an empty notice box with a checkmark is all that appears. Regardless of the product, is something broken?

        1. Zach, weird – maybe you want to copy/paste your snippet and I can take a look?

  36. Hm.. I can’t get this to work for my Woo store. I would really need this function. Neither does the
    “.woocommerce-message {display: none !important;” work in custom css or the php snippet in my functions.php file.

    Do you have any idea of what could be wrong? I am using latest versions of everything…

    1. Thanks for your feedback Adam! Can I have your website URL please? Probably your template has a lot of customization and they changed the CSS class or PHP hook. Let me know!

  37. Bad practice to use CSS to hide things.. Increases page load times and so on…

    1. Alex, thank you for your comment! Yes, I agree, hiding divs via CSS is bad practice – however if you limit your display:none to a minimum nothing will happen to your website speed. Sometimes, CSS allow for faster fixes – and in this case I bet it works faster than a PHP remove_action hook πŸ™‚

    2. Yes. 100% agree.

      Remove this message by simple add this to your functions.php


Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

Your email address will not be published. Required fields are marked *