WooCommerce 购物车通知

问题描述 投票:0回答:1

如何更改继续购物文本?

我尝试了这个剪裁,但对我不起作用:

add_filter( 'wc_add_to_cart_message_html', 'quadlayers_custom_add_to_cart_message' ); function quadlayers_custom_add_to_cart_message() { $message = 'Your product has been added to cart. Thank you for shopping with us!' ; return $message; }

产品(测试):https://paratyyogafestival.com.br/2024/ingressos/workshop-teste/

我还想更改带有消息的按钮的顺序: 打印屏幕

提前致谢。

wordpress woocommerce hook-woocommerce
1个回答
0
投票

使用过滤器时应尽量设置优先级。 在函数中,您应该使用参数,检查字符串是否存在,如果存在则替换它。 确保将此代码放入您的functions.php或自定义插件中。

add_filter( 'wc_add_to_cart_message_html', 'quadlayers_custom_add_to_cart_message', 10, 2 );

function quadlayers_custom_add_to_cart_message($message, $products){

    if (strpos($message, "Continue shopping") !== false) {
        $message = str_replace("Continue shopping", "Your custom Message", $message);
    }

    return $message;

}
© www.soinside.com 2019 - 2024. All rights reserved.