After pressing the 'Add TO BASKET' button, a "[Product] has been added to your Basket ... View basket" message is displayed.
We need to add a 2nd button to this message saying "Continue Shopping" (which returns to the SHOP page).
We thought we had found the appropriate php, but it displays "Continue" not "Continue shopping".
Amending the text in the php (below) seems not to work, then we noticed that the php (highlighted below) says "View cart", but the text that is actually displayed says "View basket". Where have we gone wrong?
PHP below is NOT formatted as 'code' - as I could not then highlight the specific areas.
**************************************************************************************************************
\* Add 2nd 'Continue' buttom to woo message see:
\* https://stackoverflow.com/questions/78064454/continue-shopping-button-next-to-view-cart-button-in-woocommerce
\*
*/
add_filter( 'wc_add_to_cart_message_html', 'filter_wc_add_to_cart_message_html', 10, 3 );
function filter_wc_add_to_cart_message_html( $message, $products, $show_qty ) {
$titles = array();
$count = 0;
$product_id = null;
foreach ( $products as $product_id =\> $qty ) {
/\* translators: %s: product name \*/
$titles\[\] = apply_filters( 'woocommerce_add_to_cart_qty_html', ( $qty \> 1 ? absint( $qty ) . ' × ' : '' ), $product_id ) . apply_filters( 'woocommerce_add_to_cart_item_name_in_quotes', sprintf( \_x( '“%s”', 'Item name in quotes', 'woocommerce' ), strip_tags( get_the_title( $product_id ) ) ), $product_id );
$count += $qty;
}
$titles = array_filter( $titles );
/\* translators: %s: product name \*/
$added_text = sprintf( \_n( '%s has been added to your cart.', '%s have been added to your cart.', $count, 'woocommerce' ), wc_format_list_of_items( $titles ) );
$message = esc_html( $added_text );
$btn_class = wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '';
$return_to = wc_get_page_permalink( 'shop' );
$message .= sprintf( ' \', esc_url( wc_get_cart_url() ), esc_attr( $wp_button_class ), esc_html_\_( '**View cart**', 'woocommerce' ) );
}
/* end of function */