WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Changing 'Out of stock' to 'coming soon& (37 posts)

  1. press_ppm
    Member
    Posted 1 year ago #

    Hi,

    I was wondering how to chamge 'out of stock' to 'coming soon'

    I found the file to change it on the single product page but how do I change it on the main list of products page?

    http://wordpress.org/extend/plugins/woocommerce/

  2. royho
    Member
    Posted 1 year ago #

    I am not sure if there are any filters to change that text...But if there are not, then you can always use PO files to do so....have a look at this -> http://wordpress.org/support/topic/plugin-woocommerce-excelling-ecommerce-rename-categories-and-products?replies=36

  3. press_ppm
    Member
    Posted 1 year ago #

    Hi,

    I gave that a go but still couldn't find or change the 'out of stock' text:
    <img src="http://i.imgur.com/fxlYg.png" alt="" title="Hosted by imgur.com" />

    Surely it's in a php file somewhere? I'm using the maya theme.

  4. IgniteWoo
    Member
    Posted 1 year ago #

    Assuming that you're not using a totally customized theme for WooCommerce that implements some of its own layout code ( such as the Shelflife theme ) ...

    Look for the loop/price.php template file and modify that.

    Change it to something like this:

    <?php $price_html = $product->get_price_html() ?>
    
    	<span class="price">
    		<?php
    		    if ( empty( $price_html ) )
    			    echo 'Coming Soon!';
    		    else
    			    echo $price_html
    		?>
    	</span>

    That's all there is to it ;-)

  5. bheadrick
    Member
    Posted 1 year ago #

    there's also a price.php under single-item, so you'll need to modify that one as well.

  6. IgniteWoo
    Member
    Posted 1 year ago #

    The original poster wrote "I found the file to change it on the single product page" so he's obviously found the price.php file in the "single-product" subdir ;-)

  7. bheadrick
    Member
    Posted 1 year ago #

    my sincere apologies for my superfluous comment!

  8. vervestudio
    Member
    Posted 1 year ago #

    not superfluous at all, I didn't know I had to change that file as well, thanks for the heads up everyone.

  9. spinach
    Member
    Posted 1 year ago #

    Hi there! I want to do the same but add a "SOLD" sign instead of the "OUT OF STOCK" sign on a product's image. Any help would be greatly appreciated. Thanks,

  10. vervestudio
    Member
    Posted 1 year ago #

    I am trying to add some text which says "Coming Soon" as above from the original post. I have tried the above code and changed my loop/price.php to look like this:

    <?php
    /**
    * Loop Price
    */

    global $product;
    ?>

    <?php /*?><?php if ($price_html = $product->get_price_html()) : ?>
    <span class="price"><?php echo $price_html; ?></span>
    <?php endif; ?><?php */?>

    <?php $price_html = $product->get_price_html() ?>

    <span class="price">
    <?php
    if ( empty( $price_html ) )
    echo 'Coming Soon!';
    else
    echo $price_html
    ?>
    </span>

    And I have changed the single-product/price.php to look like this:

    <?php
    /**
    * Single Product Price
    */

    global $post, $product;
    ?>
    <p itemprop="price" class="price">

    <?php //echo $product->get_price_html(); ?>

    <?php $price_html = $product->get_price_html() ?>

    <?php
    if ( empty( $price_html ) )
    echo 'Coming Soon!';
    else
    echo $price_html
    ?>

    </p>

    But it is still not working, any suggestions?
    Thanks

  11. boluo33
    Member
    Posted 1 year ago #

    Yo! I just managed it.

    Go to woocommerce/classes and find the file class-wc-product.php

    There are three instances of:

    $availability = __('Out of stock', 'woocommerce');

    within the file.

    I changed 'Out of stock' to 'Sold' and it worked for me.

    Lovely stuff!

  12. vervestudio
    Member
    Posted 1 year ago #

    Absolute legend! worked for me too, thanks a million

  13. bheadrick
    Member
    Posted 1 year ago #

    you shouldn't modify the core woocommerce files. That's what hooks and template files are for.

  14. spinach
    Member
    Posted 1 year ago #

    It did not work for me :( I changed all three options and nothing happened. The out of stock sign was still there unfortunately. Any other way maybe?

  15. eyebrow
    Member
    Posted 1 year ago #

    i get a fair few errors on the admin area when modfying those files.
    Who knows how to do this using hooks???

  16. bheadrick
    Member
    Posted 1 year ago #

    add_filter('woocommerce_get_availability', 'availability_filter_func');

    function availability_filter_func($availability)
    {
    $availability['availability'] = str_ireplace('Out of stock', 'Coming Soon', $availability['availability']);
    return $availability;
    }

  17. blokof
    Member
    Posted 1 year ago #

    Does somebody know how you can put another stock option in it?

    It like to give the option: delivery time 1 week, or the option: not in stock.

    Is there a plugin that can do this?

    Hope that somebody can help me with this!

  18. blokof
    Member
    Posted 1 year ago #

    Does somebody know how you can put another stock option in it?

    It like to give the option: delivery time 1 week, or the option: not in stock.

    Is there a plugin that can do this?

    Hope that somebody can help me with this!?

  19. IgniteWoo
    Member
    Posted 1 year ago #

    There aren't any hooks to add another stock option. But you can modify the single-product/price.php template file to display "Delivery time 1 week" instead of "In Stock".

  20. blokof
    Member
    Posted 1 year ago #

    The options that already displayed are fine, so i cant edit them, i just want another option in it.. Isn't there a simple way to ad an stock option?

  21. IgniteWoo
    Member
    Posted 1 year ago #

    @blokof - what status do you want to add and what is its purpose?

  22. cokeyblokey
    Member
    Posted 1 year ago #

    Just thought I'd add something to enhance the answer given by bheadrick to the OP's original question...

    To change the out of stock message for certain products only, you can add an 'if' statement with an array of the product ID's of those that you want to change the message for.

    Add this to your themes functions.php file, changing the ID's 2230 etc to match your product IDs:

    add_filter('woocommerce_get_availability', 'availability_filter_func');
    
    function availability_filter_func($availability)
    {
    if(is_single( array(2230,2232,2234,2236)))$availability['availability'] = str_ireplace('Out of stock', 'your text here', $availability['availability']);
    return $availability;
    }

    Now just the products you add to the array will have their out of stock message changed. All other products will keep the original 'out of stock' message,

    Thanks to bheadrick for the original function - it enabled me to work out how to use it for specific products!

    Hope this helps somebody out there!

  23. erfanv
    Member
    Posted 1 year ago #

    WOOCOMMERCE 2.0

    For those of you who have upgraded to WooCommerce 2.0, modify this file:
    woocommerce/classes/abstracts/abstract-wc-product.php

    As suggested by boluo33
    "There are three instances of:
    $availability = __('Out of stock', 'woocommerce');
    within the file."

    Change all three 'Out of Stock' to whatever you so desire. (In my case, I made it ' ', so that nothing shows and purchasing is simply unavailable). Cheers.

  24. IgniteWoo
    Member
    Posted 1 year ago #

    @erfanv: That is a VERY, VERY, bad way to handle things. You should never modify plugin code unless you want to lose your mods when you upgrade, or lose the ability to upgrade.

    Use this filter instead:

    return apply_filters( 'woocommerce_get_availability', array( 'availability' => $availability, 'class' => $class ), $this );

    So for example ( you gotta do part of the work ;-) -->

    add_filter( 'woocommerce_get_availability', 'change_out_of_stock', 100, 2 );
    
    function change_out_of_stock( $args, $obj ) {
    // do something here...
    }

    More here:

    http://codex.wordpress.org/Function_Reference/add_filter

    IgniteWoo Team

  25. erfanv
    Member
    Posted 1 year ago #

    Ouch. Two capital "VERY"'s?!? Humph... now to learn about filters, how they work, and how to use them...

  26. emza
    Member
    Posted 1 year ago #

    Sorry, I'm totally lost.

    IgniteWoo Team,

    If i have a child theme to customize.

    Do i put both the codes above in functions.php?

  27. aHao
    Member
    Posted 1 year ago #

    I'm sorry if this is an attempt to hijack the thread, but i've been searching the whole internet to find a simple way to put up the "out of stock" or "sold out' sign in the first place.

    So I just want my catalog to add out of stock signs when stuff are out of stock.. I can't find it how to do such simple thing.

    If anyone can help, much is appreciated!

  28. terrytsang
    Member
    Posted 1 year ago #

    Hi, just want to share some codes here for the issue above:

    //change woocommerce 'out of stock' product status to any text status you want
    add_filter('woocommerce_get_availability', 'custom_get_availability');

    function custom_get_availability($availability)
    {
    $availability['availability'] = str_ireplace('Out of stock', 'Coming Soon...', $availability['availability']);
    //$availability['availability'] = str_ireplace('Out of stock', 'Sold Out!', $availability['availability']);
    //$availability['availability'] = str_ireplace('Out of stock', 'Call for Price', $availability['availability']);

    return $availability;
    }

  29. t0m4s05
    Member
    Posted 1 year ago #

    @terrytsang where i'm supposed to paste that code? in which file?

    Thanks in advanced

  30. terrytsang
    Member
    Posted 1 year ago #

    @t0m4s05, you need to past the code in functions.php in your theme folder.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.