Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress - Woocommerece remove "Added to Cart" message

I'm looking to remove the wording and area that says "Product Successfully Added to Cart" after I add an item to the cart. I just want there to be nothing, no message and no space for the message.

Here's the site: http://www.tinytreasurehunts.com The code is in woocommerece-functions.php

Any thoughts?

like image 274
user1803660 Avatar asked Dec 24 '12 18:12

user1803660


People also ask

How do I change the add to cart message in WooCommerce?

All you need to do is go to WooCommerce > Settings and open the Products tab. Then, check the option to Redirect to the cart page after successful addition in the Add to cart behavior section. Don't forget to save the changes.

How do I turn off WooCommerce notices?

add_filter( 'wc_add_to_cart_message_html', '__return_false' ); Add it to the theme's functions. php file or you can use the Code Snippets plugin. It should remove this notification from the site for you.


2 Answers

To solve this at PHP level, add the following template file (and structure) to your theme:
/wp-content/themes/YOUR-THEME/woocommerce/shop/messages.php:

<?php
/**
 * Show messages
 *
 * @author      brasofilo
 * @package     WooCommerce/Templates
 * @version     1.6.4
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

if ( ! $messages ) return;

foreach ( $messages as $message ) : 
    // The message does not contain the "add to cart" string, so print the message
    // http://stackoverflow.com/q/4366730/1287812
    if ( strpos( $message, 'added to your cart' ) === false ) :
        ?>
            <div class="woocommerce-message"><?php echo wp_kses_post( $message ); ?></div>
        <?php 
    endif;
endforeach;

See: Template Structure + overriding templates via a theme

like image 67
brasofilo Avatar answered Oct 19 '22 21:10

brasofilo


Use one of these:

Older version

$woocommerce->clear_messages(); 

Version 2.3

wc_clear_notices();
like image 31
Arni Cinco Avatar answered Oct 19 '22 21:10

Arni Cinco