Replace the WooCommerce “add to cart” button on shop page with a link to the product page

The following code renames the default “Add to cart” button and replace the “Add to cart” action on the shop/archive page with a link to the product page. Instead of the item being added to your cart, it will only open up the product page.


function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );


function replace_add_to_cart() {
global $product;
$link = $product->get_permalink();
    echo do_shortcode('<a href="'.$link.'" class="button addtocartbutton">Choose options</a>');

Was this helpful? Please buy me a coffee

This code should be added to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update.

Share your thoughts

Your email address will not be published. Required fields are marked *