Skip to content

Instantly share code, notes, and snippets.

@emre-edu-tech
Last active October 13, 2024 07:17
Show Gist options
  • Save emre-edu-tech/6c61eb561a0321df94bd29ea02770649 to your computer and use it in GitHub Desktop.
Save emre-edu-tech/6c61eb561a0321df94bd29ea02770649 to your computer and use it in GitHub Desktop.
Woocommerce - Change add to cart button to a Product Details Button on product archive page
<?php
add_filter( 'woocommerce_loop_add_to_cart_link', 'replace_add_to_cart_button_on_product_archive', 10, 2 );
function replace_add_to_cart_button_on_product_archive($button, $product) {
$button_text = __("Show Product", "textdomain");
$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