1
votes

Good afternoon,

I have been searching the internet all morning trying to find away to add a 'view cart' link under my 'add to cart' button on the single product page.

I am trying to do this as I only want a link to the cart to be visible when there are items in the cart, without adding it to the main site menu.

I tried this snippet but it did nothing:

add_action( 'woocommerce_after_single_product_summary', 'add_cart_link', 0   );

function add_custom_field() {
global $post;

echo "something here";

return true;
}

I am not sure what the best solution is... has anyone come across a solution that may work?

1

1 Answers

1
votes

Add below code to your theme's functions.php.

add_action('woocommerce_after_add_to_cart_button','view_cart_text');

function view_cart_text(){
    echo '<button type="submit" class="single_add_to_cart_button button alt">View cart</button>';
}

Obviously you need to do some CSS or styling according to your theme.But it will give you the result what you want to achieve.