Reputation: 131
I have coded a custom 'Added to cart' message for WooCommerce and after that I used the conditional tag 'is_cart()' to disable the message on the cart page but it still shows up.
How can I disable the message being shown on cart page?
Here is my code example:
function iw_add_to_cart_message_function( $message, $product_id ) {
if (!is_cart()) {
$message = sprintf(esc_html__('%s has been added by to your cart pompidompidom.','iwebbers'), get_the_title( $product_id ) );
return $message;
}
}
add_filter( 'wc_add_to_cart_message', 'iw_add_to_cart_message_function', 10, 2 );
I just tried the following IF STATEMENT and it works:
global $woocommerce;
if (get_option('woocommerce_cart_redirect_after_add')=='no') {
Upvotes: 1
Views: 76
Reputation: 189
Function wc_add_to_cart_message
it Return message rather than add it.
go refer link: docs.woocommerce
Upvotes: 1