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; }
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; }
4 Comments. Leave new
Hi there, the above works to change the add to cart ‘message’, but it is deleting the add to cart button on the right side. Is there another snippet to use that will keep the button in place? I’m trying to change the word “cart” to “order” in both instances – message and the button (View cart – View order).
Your help is appreciated!
Hi Michele
Sure, Always happy to help you.
Could you please share your site url through Live Online Chat ?
Me to
Hello, kindly help with this snippet
Hi there, the above works to change the add to cart ‘message’, but it is deleting the add to cart button on the right side. Is there another snippet to use that will keep the button in place? I’m trying to change the word “cart” to “order” in both instances – message and the button (View cart – View order).