Solution for : Woocommerce replace add to cart button with custom button/link
Replacing the button add to cart by a link to the product in Shop and archives pages for woocommerce 3+
1 2 3 4 5 6 7 | 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:
No comments:
Post a Comment