I recently added code snippet to my functions.php child theme file which task is to echo a "Read More" button under all products which leads the user to the click product page. The product-id link is not working. Here is the code:
/*-ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */
add_action('woocommerce_after_shop_loop_item','replace_add_to_cart');
function replace_add_to_cart() {
global $product;
$link = $product->get_permalink();
echo do_shortcode('<br><button link="' . esc_attr($link) . '">Read more</button>');
}
Right now, It just shows a button text(without class) which does not redirect to any product link. I want to add the primary button to it as well.