Created
September 22, 2017 20:45
-
-
Save lukecav/d189bf3aba7938f9ec0e7801d5313732 to your computer and use it in GitHub Desktop.
Remove add to cart notices in WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/34645095/remove-hide-woocommerce-added-to-cart-message-but-keep-display-coupon-applied-me