Replace add to cart button with a read more linked to product page on shop pages in WooCommerce 3 Replace add to cart button with a read more linked to product page on shop pages in WooCommerce 3 wordpress wordpress

Replace add to cart button with a read more linked to product page on shop pages in WooCommerce 3


Replacing the button add to cart by a link to the product in Shop and archives pages for woocommerce 3+:

add_filter( 'woocommerce_loop_add_to_cart_link', 'replacing_add_to_cart_button', 10, 2 );function replacing_add_to_cart_button( $button, $product  ) {    $button_text = __("View product", "woocommerce");    $button = '<a class="button" href="' . $product->get_permalink() . '">' . $button_text . '</a>';    return $button;}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

This code is tested on WooCommerce 3+ and works. You can customize the text of button and you will get something like:

enter image description here


Add these to your functions.php file in the theme folder

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');


In case it helps, this worked for me to apply this solution only to simple products, since variable products don't "add to cart" on archive pages anyway. This way it can be clearer that a product has more options (if it is variable). I also changed the text of "select options" to "more options" in the example below (since not all products in my case would be purchasable even after viewing the single product page's url, which is another non-topical idea for this thread):

// changes the "select options" text. Forget who to give credit to for this.add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) {global $product;if ( $product->is_type( 'variable' ) ) {    $text = $product->is_purchasable() ? __( 'More Options', 'woocommerce' ) : __( 'Read more', 'woocommerce' );}return $text;}, 10 );/** * remove add to cart buttons on shop archive page */add_filter( 'woocommerce_loop_add_to_cart_link', 'replacing_add_to_cart_button', 10, 2 );function replacing_add_to_cart_button( $button, $product  ) {if ( $product->is_type( 'simple' ) ) {$button_text = __("View product", "woocommerce");$button = '<a class="button" href="' . $product->get_permalink() . '">' . $button_text . '</a>';}return $button;}