Hello, I would like to change the functionality of the "Add to Cart" button to only forward to the product page without adding to the cart
add_filter( 'woocommerce_loop_add_to_cart_link', 'redirect_to_product_page', 10, 2 ); function redirect_to_product_page( $link, $product ) { global $woocommerce; $product_cat = wp_get_post_terms( $product->get_id(), 'product_cat', array( 'fields' => 'slugs' ) ); $product_cat = isset( $product_cat[0] ) ? $product_cat[0] : ''; $link = get_site_url() . '/product/' . $product_cat . '/' . $product->get_slug() . '/'; return $link; }
This is the code I tried but it just replaces "add to cart" with the correct url
You can remove the button and put it back with your own information. This also allows you to change the button text: