Skip to content

Instantly share code, notes, and snippets.

@lukecav
Created December 5, 2017 03:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukecav/807ccf489637950113e9c3ca69ef8113 to your computer and use it in GitHub Desktop.
Save lukecav/807ccf489637950113e9c3ca69ef8113 to your computer and use it in GitHub Desktop.
Replacing the button add to cart by a link to the product in Shop and archives pages in WooCommerce
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment