Remove “You cannot add another (product) to your cart”
-
Hi, We’re using ‘add to checkout’ links, with the ‘Sold individually’ selected. We want to remove the error people are getting when they click the link again, if they didn’t purchase first time.
I’ve tried…
function remove_added_to_cart_notice()
{
$notices = WC()->session->get(‘wc_notices’, array());
foreach( $notices[‘success’] as $key => &$notice){
if( strpos( $notice, ‘You cannot add another (product) to your cart’ ) !== 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);I can remove the message, but not the whole thing…
add_filter( 'woocommerce_cart_product_cannot_add_another_message', '__return_false' );
and I can remove all notices, but we need to keep the “An account is already registered with your email address. Please log in.” notice.I’ve search and tried numerous filters, but noe work. Is there something like this?
add_filter( 'wc_added_to_cart_notice', '__return_false' );
or
add_filter( 'woocommerce_added_to_cart_notice', '__return_false' );
Any help appreciated. Thanks
The page I need help with: [log in to see the link]
- The topic ‘Remove “You cannot add another (product) to your cart”’ is closed to new replies.