Replace add to cart link in category pages

PHOTO EMBED

Tue Jul 19 2022 08:08:08 GMT+0000 (Coordinated Universal Time)

Saved by @georgi_bogdanov #php

add_filter( 'woocommerce_loop_add_to_cart_link', 'replace_add_to_cart_button', 10, 2 );
function replace_add_to_cart_button( $button, $product ) {
  if (is_product_category() || is_shop()) {
    $button_text = __("View Product", "woocommerce");
    $button_link = $product->get_permalink();
    $button = '<a class="button" href="' . $button_link . '">' . $button_text . '</a>';
    return $button;
  }
}
content_copyCOPY