Mary Mary - 6 months ago 123
PHP Question

Hide Added to Cart message on checkout page 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

Answer

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:

// define the wc_add_to_cart_message 
function empty_wc_add_to_cart_message( $message, $product_id ) { 
    return ''; 
}; 
         
// add the filter 
add_filter( 'wc_add_to_cart_message', 'empty_wc_add_to_cart_message', 10, 2 );

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;
}
Comments