This topic has 4 replies, 2 voices, and was last updated 2 years, 2 months ago ago by Rose Tyler
Is there any way to change the message after add to cart? I had tried to add a snippet in function.php but it still does not work
my snippet like this:
add_filter( ‘wc_add_to_cart_message’, ‘addcart_message’, 10, 2 );
function addcart_message($message,$product_id){
$message = sprintf(esc_html__(‘已成功將 %s 加到購物車’,’tm-organik’), get_the_title( $product_id ) );
return $message;
}
Hello,
If you need to translate texts, create a translation for the theme and Core plugin – https://www.8theme.com/documentation/xstore/theme-translation/base-theme-translation/
Regards
but how do i change that exact message even not in other language?
Hello,
You have a few options on how to modify that text :
1/ You may copy next file xstore/woocommerce/product-added-to-cart.php to your child-theme/woocommerce/product-added-to-cart.php and change this line of code due to your needs -> https://prnt.sc/g8jWQZwT5Chj
2/ According to the fact we are using the default wc_print_notice function and it has its own filter -> https://prnt.sc/O8hkQwF9fC9X you may modify your text just like you did but with the filter named -> ‘woocommerce_add_message’
Regards
Tagged: add to cart, change, customize, success message, themes, woocommerce, wordpress
The issue related to '‘Changing the success Add to cart message’' has been successfully resolved, and the topic is now closed for further responses