Change “HAS BEEN ADDED TO YOUR CART” WOOCOMMERCE DEFAULT Message WordPress

Looking for change “HAS BEEN ADDED TO YOUR CART” default Woocommerce message by your own? well In WordPress Woocommerce when you added Product to your Shopping Cart you may notice at Top “Product Name + HAS BEEN ADDED TO YOUR CART” success notice message showing by Woocommerce. if you want to change it by some spicy word you can do it by use of Woocomerce wc_add_to_cart_message filter. Below is sample code which needs to add in active theme functions.php file and replace “has been added to your cart.” text string by your own.

add_filter( 'wc_add_to_cart_message', 'wdo_custom_wc_add_to_cart_message', 10, 2 ); 
 
function wdo_custom_wc_add_to_cart_message( $message, $product_id ) { 
    $message = sprintf(esc_html__('« %s » has been added to your cart.','tm-organik'), get_the_title( $product_id ) ); 
    return $message; 
}

Change HAS BEEN ADDED TO YOUR CART WOOCOMMERCE DEFAULT Message WordPress

With use of above custom code if you see VIEW CART button deleted and you want it? please find below code which help you in change Add to cart default message with keep VIEW CART button after message.

add_filter( 'wc_add_to_cart_message', 'wdo_custom_wc_add_to_cart_message', 10, 2 ); 
 
function wdo_custom_wc_add_to_cart_message( $message, $product_id ) { 
    $new_message = sprintf(esc_html__('« %s » has been added to your cart.','tm-organik'), get_the_title( $product_id ) ); 
    $cart_url  = wc_get_cart_url();
    $message    = sprintf('%s %s', $cart_url, __( 'View Cart', 'woocommerce' ), $new_message );
    return $message; 
}

Leave a Comment

Scroll to Top