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?
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.
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.
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
Use one of these:
Older version
$woocommerce->clear_messages();
Version 2.3
wc_clear_notices();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With