Support » Plugins » WooCommerce Add Link after Out of Stock text

  • Brand new to customizing my wordpress code.

    I would like to be able to add a text link on the line after “Out of Stock” when one of my products is out of stock. Ideally, I’d like to pull a string of html that can be stored within the product. I was originally thinking using a custom attribute, but if there is a better place, please let me know.

    Searching the forums, I’ve determined that I need to add a filter to my theme’s functions.php file. Here’s what I have:

    add_filter( 'woocommerce_get_availability', 'custom_get_availability', 1, 2);
    // Our hooked in function $availablity is passed via the filter!
    function custom_get_availability( $availability, $_product ) {
    if ( !$_product->is_in_stock() ) $availability['availability'] = __('Out of Stock', 'woocommerce');
    return $availability;

    I can change the text, but how to I go about adding a link to this? I’m under the impression that bringing html in from an attribute takes some strong ninja skills. Let’s assume my custom attribute is called “myattribute”

  • The topic ‘WooCommerce Add Link after Out of Stock text’ is closed to new replies.