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!

woocommerce-remove-was-successfully-added-to-cart-message
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
* @author        Rodolfo Melogli
* @compatible    WooCommerce 5
* @community     https://businessbloomer.com/club/
*/

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
* @author        Rodolfo Melogli
* @compatible    WC 5
* @community     https://businessbloomer.com/club/
*/

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 custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Custom Add to Cart URLs – The Ultimate Guide
    In WooCommerce you can add a product to the cart via a custom link. You just need to use the “add-to-cart” URL parameter followed by the product ID. This tutorial will show you how to create custom URLs to add simple, variable and grouped products to the cart – as well as defining the add […]
  • WooCommerce Visual Hook Guide: Single Product Page
    Here’s a visual hook guide for the WooCommerce Single Product Page. This is part of my “Visual Hook Guide Series“, through which you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can copy/paste). If you like this guide and it’s helpful to you, let me know in the comments! […]
  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce: How to Fix the “Cart is Empty” Issue
    For some reason, sometimes you add products to cart but the cart page stays empty (even if you can clearly see the cart widget has products in it for example). But don’t worry – it may just be a simple cache issue (and if you don’t know what cache is that’s no problem either) or […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent 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. Follow @rmelogli

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

  1. Hi Rodolfo,
    thanks for snippet.
    Alternatively it’s possible to show mini cart dropdown after item added to Cart?

    1. Hi Vinz, 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. Hello Redolfo, Thank you for all your help, you are saving a lot of us with your knowledge ๐Ÿ™‚

    One question if I may – this “REMOVE โ€œX has been added to your cartโ€ Message” works perfect, but is it possible to hide all messages that appears in that wrapper? For Example, if I remove something from my Cart there is message “”X has been removed. Undo?” – so I would like to get rid of that, and everything else that might be showing on that place.

    Thank you, and thanks once again for everything.

    1. Hello Marin, 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!

  3. HI

    Thanks
    but this function does not work for me
    any suggestion?

    1. Sorry, works for me. Try with a different theme and no other plugins but Woo

  4. This page is just amazing. Thank you for sharing your knowledge with us. Don’t have to look anywhere else for WooCommerce customisations ๐Ÿ™‚

    1. Thanks!

  5. This worked for me after looking all through my dashboard at how to remove it and googling various things so THANK YOU!

    The reason I wanted it removed from mine was on the neve theme, the pop up would appear behind the images which just looked unprofessional so I am so happy that this worked!

    1. Awesome!

  6. I have used your code, and it works fine
    but I need other help,

    I want to hide โ€œmessagesโ€ product that cannot be added to the cart,

    I added this code in CSS to hide product error messages that canโ€™t be added to the basket, it works

    .woocommerce-error {
    display: none;
    }
    after I added the code, โ€œmessageโ€ the password error was also hidden,

    I donโ€™t want the password error message to be hidden,

    please help me to hide โ€œmessagesโ€ product cannot be added to the basket and โ€œmessagesโ€ password error when user login is still visible
    thank you

    1. Ady, 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!

  7. Hi Rodolfo. Amazing guide, as usual!
    Can I also disable the page reload after the product is being added to the cart?
    I created a popup with Elementor Pro that triggers whenever someone adds a product to a cart, yet it only shows on Archive pages.
    On the product page itself, it loads for a millisecond and then the page reload itself.

    Is this code prevent from that happening?

    1. No this does not prevent the page reload, it only hides the notice

  8. Still works for me! Thanks bro.

    1. Awesome!

  9. 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!
    Sumit

    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!

  10. 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

  11. 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?

  12. 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 ๐Ÿ™‚

  13. 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 ๐Ÿ™‚

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

    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

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

  16. 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!

  17. 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

  18. 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

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

    Thanks!

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

  20. 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?

    david
    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 ๐Ÿ™‚

  21. Hi Rodolfo,

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

    Cheers,
    Anuj

    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

  22. 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

  23. 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,
    Petar

  24. 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 ๐Ÿ™‚

  25. Hey!

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

    wc_add_to_cart_message_html 

    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.

    Cheers

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

  26. 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

  27. MERCI !! Thanks a lot !

    1. You’re welcome Lucien!

  28. 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]);
        print_r(array_values($bng_order)[0][url][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 ๐Ÿ™‚

  29. 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?

  30. 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’;

  31. 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:
    https://lubiland.gg/register-gg-domain-name/
    Buttons shortcodes look like this:
    [button title=”Add to basket” icon=”icon-basket” icon_position=”left” link=”https://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:
    https://lubiland.gg/register-gg-domain-name/#email
    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=”https://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.
    Lubi

    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!

  32. 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!

      1. This is EXACTLY what I need but unfortunately this code does not seem to work for me. I would like to MOVE the “Product X had been added to your cart” bar along with the “View Cart” button to the bottom of the viewport. At the moment, it covered my sticky site menu.

        This does remove it:
        add_filter( ‘wc_add_to_cart_message_html’, ‘__return_null’ );

        But I can’t figure out how to place it where I want it. Hope this is just something simple!

        Thanks!

        1. Hi Mark, 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!

  33. 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.

    Thanks!

    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! ๐Ÿ™‚

  34. 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! ๐Ÿ™‚

  35. 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 https://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

    Thanks

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

      
      $return_to = 'https://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.

            Cheers

            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;
      }
      
      
  36. 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!

  37. 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?

    Regards

    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 ๐Ÿ™‚

  38. 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

  39. 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 ๐Ÿ™‚

  40. 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

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

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

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

  42. 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;
    }

  43. 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?

  44. 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!

  45. 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

      add_filter(‘wc_add_to_cart_message’,false);

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

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