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:)