admin管理员组文章数量:1322038
I would like to change the "Product has been added to your cart." text for variable products to include the variation.
For example if I added a size 7 Shoe to my cart it should say: "Shoe in Size 7 was added to your cart"
What do I have to edit to change this?
I would like to change the "Product has been added to your cart." text for variable products to include the variation.
For example if I added a size 7 Shoe to my cart it should say: "Shoe in Size 7 was added to your cart"
What do I have to edit to change this?
Share Improve this question edited Sep 21, 2020 at 1:45 Jesse Nickles 7357 silver badges19 bronze badges asked Mar 15, 2018 at 4:30 harveyharvey 2151 gold badge4 silver badges13 bronze badges2 Answers
Reset to default 5add_filter( 'wc_add_to_cart_message', 'my_add_to_cart_function', 10, 2 );
function my_add_to_cart_function( $message, $product_id ) {
$message = sprintf(esc_html__('« %s » has been added by to your cart.','woocommerce'), get_the_title( $product_id ) );
return $message;
}
The above code will help you to change the message. Since by knowing the hook wc_add_to_cart_message
you can improve the code
add_filter( 'wc_add_to_cart_message', 'custom_wc_add_to_cart_message', 10, 2 );
function custom_wc_add_to_cart_message( $message, $product_id ) {
$message = sprintf( '%s has been added to your selection.', get_the_title( $product_id ) );
return $message;
}
Hope this will help you:)
本文标签: filtersHow to modify quotProduct has been added to your cartquot in WooCommerce
版权声明:本文标题:filters - How to modify "[Product] has been added to your cart" in WooCommerce? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742107799a2421103.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论