Changing the success Add to cart message

This topic has 4 replies, 2 voices, and was last updated 2 years, 3 months ago ago by Rose Tyler

  • Avatar: PureInStudio
    PureInStudio
    Participant
    September 5, 2022 at 11:23

    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;
    }

    3 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 5, 2022 at 14:16

    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

    Avatar: PureInStudio
    PureInStudio
    Participant
    September 6, 2022 at 03:54

    but how do i change that exact message even not in other language?

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 6, 2022 at 08:20

    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

  • Viewing 4 results - 1 through 4 (of 4 total)

The issue related to '‘Changing the success Add to cart message’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.