I am working on WooCommerce site, for some reason I want to display "Continue Shopping" button and "View Cart" button together after adding product to the cart. I found the file wc-cart-function.php that says Output success message to show message but I couldn't return view cart and continue shopping's $message variable with single return $message
.
Thanks in advance.
I believe you can do it this way.
function filter_wc_add_to_cart_message_html( $message, $products ) {
$return_to = apply_filters(
'woocommerce_continue_shopping_redirect',
wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( 'shop' )
);
$continue = sprintf(
'<a href="%s" class="button wc-forward">%s</a>',
esc_url( $return_to ),
esc_html__( 'Continue shopping', 'woocommerce' )
);
$message .= $continue;
return $message;
};
add_filter( 'wc_add_to_cart_message_html', 'filter_wc_add_to_cart_message_html', 10, 2 );
For more details take a look at "wc_add_to_cart_message_html" hook.