WordPress.org

Ready to get started?Download WordPress

Forums

Woocommerce : change Out of Stock text (11 posts)

  1. Jud Haynes
    Member
    Posted 1 year ago #

    I'm loving Woocommerce these days. Most items I've wanted to update have been easy to find but I've hit a couple snags. Looking at you MikeJolley, thinking you can help here.

    1. I'd like to change the words "Out of Stock" to "Currently Unavailable" on a product page when it is set to "Out of Stock" in the admin tool. I thought it would be a simple change but have hit every wall trying to figure it out.

    Thanks so much for the help!

  2. SeriousSam
    Member
    Posted 1 year ago #

    We're looking at doing the same - we don't intend to stock every product that we supply, but we still want to display full product info including prices.

    We can use the out of stock functionality to prevent people from being able to order the parts online while still seeing the price, but rather than the site displaying 'out of stock', we would like it to say 'call for availability info'. And we don't like the purple text, so we'd want to change that.

    Can anyone help?

  3. terrytsang
    Member
    Posted 1 year ago #

    @Jud Haynes, you can try below code:

    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'] = __('Currently Unavailable', 'woocommerce');
    return $availability;
    }

  4. terrytsang
    Member
    Posted 1 year ago #

    @SeriousSam, you can try below code:

    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'] = __('call for availability info', 'woocommerce');
    return $availability;
    }

  5. rawlsenterprises
    Member
    Posted 10 months ago #

    If nobody has told you…. Thank you Terry. :-)

  6. terrytsang
    Member
    Posted 10 months ago #

    Hi rawlsenterprises, thank you, i feel great as can help you all :) cheers!

  7. editora
    Member
    Posted 10 months ago #

    thanks too!

  8. alcain
    Member
    Posted 8 months ago #

    Hi terrytsang
    Perfect, I was searching for this fix also!
    Another BIG thank you from me :)

  9. suefenton
    Member
    Posted 8 months ago #

    @terrytsang, this is exactly what I'm looking for, thank you, but I'm new to web building and am teaching myself. Where do you insert this code?

  10. terrytsang
    Member
    Posted 8 months ago #

    Thanks all :)

    @suefenton, you need to put the code to your functions.php file inside your theme folder.

    more details can refer my tutorial

  11. 4jDesigns
    Member
    Posted 8 months ago #

    Thanks Terry! Saved me a whole lot of messing around.

Topic Closed

This topic has been closed to new replies.

About this Topic