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

woocommerce remove view cart message
woocommerce-notices-wrapper hook
woocommerce add message to cart page
woocommerce added to cart alert
remove add to cart button woocommerce css
woocommerce related products remove add to cart
woocommerce hide price and add to cart button
woocommerce edit notice messages

I'm trying to remove or hide the added to cart message at the top of my WooCommerce checkout page (I have removed the cart page so this message is showing up on the checkout page). I tried adding this to my CSS:

.woocommerce-message {display: none;}. 

Although this hides the added to cart message as I want it to, it also hides the coupon applied message, which I do not want hidden.

Next I tried this code snippet from the Business Bloomer blog in the functions.php file:

// Removes Product Successfully Added to Cart

add_filter( 'wc_add_to_cart_message', 'custom_add_to_cart_message' );

function custom_add_to_cart_message() {

echo '<style>.woocommerce-message {display: none !important;}</style>';

}

This hides the text, but the styles applied to the div with the class of .woocommerce-message are still visible, including background-color, padding etc. So I'm left with a rectangle at the top of my page with no text in it.

Any thoughts on how I can completely hide the .woocommerce-message div just for the added to cart message, but not the .woocommerce-message div for the coupon applied message or any other messages would be appreciated!


Update: 18/05/2018 Please refer to bellmountain's much simpler answer for the correct way to do this.

Add this code to your themes functions.php file. It will remove only that message. It should trigger on just the pages where it is likely to occur.

function remove_added_to_cart_notice()
{
    $notices = WC()->session->get('wc_notices', array());

    foreach( $notices['success'] as $key => &$notice){
        if( strpos( $notice, 'has been added' ) !== false){
            $added_to_cart_key = $key;
            break;
        }
    }
    unset( $notices['success'][$added_to_cart_key] );

    WC()->session->set('wc_notices', $notices);
}
add_action('woocommerce_before_single_product','remove_added_to_cart_notice',1);
add_action('woocommerce_shortcode_before_product_cat_loop','remove_added_to_cart_notice',1);
add_action('woocommerce_before_shop_loop','remove_added_to_cart_notice',1);

Don't worry about using that css you've tried.

Remove/Hide Woocommerce attached to Cart Message but Keep , I'm trying to remove or hide the added to cart message at the top of my to Cart Message but Keep/Display Coupon Applied Message". Hide Added to Cart message in Woocommerce. 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 Solutions


this worked for me:

add_filter( 'wc_add_to_cart_message', 'remove_add_to_cart_message' );

function remove_add_to_cart_message() {
    return;
}

Remove add to cart notices in WooCommerce · GitHub, Remove/Hide Woocommerce Added to Cart Message but Keep/Display Coupon Applied Message. Posted by: admin November 17, 2017 Leave a comment. 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!


I`m using this:

add_filter( 'wc_add_to_cart_message_html', '__return_null' );

WooCommerce, Remove add to cart notices in WooCommerce. GitHub Gist: instantly share code, notes, and snippets. https://stackoverflow.com/questions/34645095/remove-​hide-woocommerce-added-to-cart-message-but-keep-display-coupon-applied-​me  Remove add to cart notices in WooCommerce. GitHub Gist: instantly share code, notes, and snippets.


This should work to hide the product added to cart message

add_filter( 'wc_add_to_cart_message', 'remove_cart_message' );

function remove_cart_message() {
    return;
}

WooCommerce: Hide coupon box on checkout page if a coupon is , WooCommerce - hide the coupon form on the cart or checkout page, but leave page, but leave coupons enabled for use with plugins like Smart Coupons and URL Coupons Just make sure to remove the first line <?php from this code snippet if it's Then i only want that this message appear only when the bill is >​27$. There is no option in the WooCommerce admin interface that would allow you to hide or disable the "add to cart" button on your e-commerce site. what We would be presenting in this tutorial would allow you to remove the add to cart button quick and easy.


Just used the following and it worked fine:

div.woocommerce-message {
    display: none !important;
}

Hope this helps!

How to Hide the WooCommerce Coupon code field, WooCommerce: Hide coupon box on checkout page if a coupon is When you enable the use of coupons, WooCommerce adds a field on the cart page, and a box notice on the checkout page. But, if you enter a coupon in the cart page, and apply that coupon to the order, the notice is still displayed on the  Hide WooCommerce Coupon Codes Applied. If you want to hide coupon codes entirely from your shop because you’re automatically applying them, there’s one more step you’ll need to take. The coupon code applied will be shown to customers as they complete their order, regardless of how the coupon is applied.


Rename or Hide Coupon Code fields with WooCommerce, 1) Disable coupon code completely on your WooCommerce store. 2) Hide on the cart page and display on the checkout page. a day and a recent request I had was agreed to be valuable enough to add to Leave a Reply. WooCommerce - hide the coupon form on the cart or checkout page, but leave coupons enabled for use with plugins like Smart Coupons and URL Coupons - wc-hide-coupons-cart-checkout.php Skip to content All gists Back to GitHub


WooCommerce: Remove / Edit "Added to Your Cart" Message, Hide coupon code fields or rename them to lower the chance of the form on the cart/checkout pages, but leave coupon use enabled otherwise. plugins like Smart Coupons and URL Coupons that apply discounts without message displayed and the customer has to click to enter their code, but it's still  Unfortunately, unlike the rest of WooCommerce default elements, the coupon form is hardcoded into the Cart table i.e. there is no PHP function that can be “unhooked” via “remove_action”. In plain English, there is no other way (as of now) to remove that coupon code via PHP, so we must use some annoying CSS.


How to Hide WooCommerce Coupon Fields, Save my name, email, and website in this browser for the next time I comment. PHP Snippet 1: Apply a Coupon Programmatically if a Product is in the Cart. Notes: Create a coupon code that you want to apply once a certain product is added to cart (go to WooCommerce / Coupons / Add New and decide your coupon code.