Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 434
Mary Avatar asked May 09 '16 22:05

Mary


People also ask

How do I hide additional information in WooCommerce checkout?

All you need to do is install a plugin like YITH WooCommerce Tab Manager and activate it. Once active, use the plugin options to remove, change or delete the WooCommerce tabs. You can even create your custom tab. The benefit of using this method is that is the most simple and the most beginner-friendly.

How do I hide Add to cart button in WordPress?

If the filter is_purchasable is set to true for the product, the 'Add to Cart' button is displayed, else the button is hidden. And there lay the answer. So, you just need to add the following: add_filter( 'woocommerce_is_purchasable', '__return_false');


2 Answers

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;
}
like image 146
LoicTheAztec Avatar answered Oct 02 '22 22:10

LoicTheAztec


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

like image 38
Shivpal Singh Avatar answered Oct 02 '22 22:10

Shivpal Singh