Add variation to the added to cart message
-
Hi, I’m using the filter given on stackoverflow the get at the message shown when something is added to the cart. It works well.
However, I want to add the variation to the product’s name. Instead of “Red T-shirt has been added to your basket.” I need “Red T-shirt large has been added to your basket.”
Can any of you clever people help? Here’s the filter:
add_filter ( 'wc_add_to_cart_message', 'wc_add_to_cart_message_filter', 10, 2 ); function wc_add_to_cart_message_filter($message, $product_id = null) { $titles[] = get_the_title( $product_id ); $titles = array_filter( $titles ); $added_text = sprintf( _n( '%s has been added to your cart.', '%s have been added to your cart.', sizeof( $titles ), 'woocommerce' ), wc_format_list_of_items( $titles ) ); $message = sprintf( '%s <a href="%s" class="button">%s</a> <a href="%s" class="button">%s</a>', esc_html( $added_text ), esc_url( wc_get_page_permalink( 'checkout' ) ), esc_html__( 'Checkout', 'woocommerce' ), esc_url( wc_get_page_permalink( 'cart' ) ), esc_html__( 'View Cart', 'woocommerce' )); return $message; }
Be happy for ever,
Steve
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Add variation to the added to cart message’ is closed to new replies.