functions – WooCommerce, change “Add to Cart” to “Link to Product”, only for specific categories

Question

I am using the code below to change the “Add to Cart” to “Read More” and link to the product page.
My question is how to do that ONLY for specific product categories.

add_filter( 'woocommerce_loop_add_to_cart_link', 'replace_loop_add_to_cart_button', 10, 2 );
if( $product->is_type( 'variable' ) ) return $button;
$button_text = __( "Read More", "woocommerce" );
return '<a class="button" href="' . $product->get_permalink() . '">' . $button_text .          '</a>';
}

0
geoplous 2 weeks 2023-05-23T03:28:21-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse