Hi,
I’m trying to add a text link from the product page to itself. Sounds redundant but it’s for products that are shown elsewhere on my website, in a list. It’s so users can click and be taken to the shop page to see more information, rather than add the products directly to their carts. I would only like it to display for products that are currently in stock.
So far I found a bit of code that displays a message when an item is in stock, but I cannot customize the message, let along make it link to the product page:
// Hook in
add_filter( 'woocommerce_get_availability', 'custom_override_get_availability', 1, 2);
// The hook in function $availability is passed via the filter!
function custom_override_get_availability( $availability, $_product ) {
if ( $_product->is_in_stock() ) $availability['availability'] = __('In Stock', 'woocommerce');
return $availability;
}
Further searching for code snippets hasn’t led me to any solutions. If you know a way of making this work that would be amazing.
Thanks!
-Adam