简体   繁体   中英

Woocommerce - adding link under add to cart button

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM