Custom “Added to Cart” Message
This snippet customizes the message displayed when a product is added to the cart, allowing for more personalized feedback.
PHP
function custom_add_to_cart_message( $message, $products ) {
$titles = array();
foreach ( $products as $product_id => $qty ) {
$titles[] = get_the_title( $product_id );
}
return sprintf( '%s has been added to your cart. <a href="%s">View Cart</a>', implode( ', ', $titles ), wc_get_cart_url() );
}
add_filter( 'wc_add_to_cart_message_html', 'custom_add_to_cart_message', 10, 2 );
Snippet Feedback
Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.
SHARED BY
1 Views