New Landing How can we help? Themeforest Theme Support Neighborhood Out of Stock on Variable Product to Sold Out – NOT BANNER

Viewing 8 posts - 1 through 8 (of 8 total)
  • #125542
    eyedhaas
    Member
    Post count: 5

    Hello,

    I am using the Neighborhood theme for an apparel. For the woocommerce single product page, I am using variable products and am looking to change the “out of stock” text that pops up when a quantity variation = 0 to “sold out”. For example, http://ponoprints.com/product/fuchsia-floral-pocket-tee/ – on this product I have sold out of x-large but still have mediums and smalls. I did change the banner “out of stock” text to “sold out” for products that are entirely sold out.

    Thanks for your help. A little point but one I can’t find in the php to correct.

    Isaac

    Attachments:
    You must be logged in to view attached files.
    #125668
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please refer this article https://support.woothemes.com/hc/en-us/articles/202845976-How-to-Change-In-Stock-Out-of-Stock-Text. Hope that should help and let me know your feedback.

    Thanks
    Mohammad

    #125872
    eyedhaas
    Member
    Post count: 5

    Thanks for sending me the php code for out of stock to sold out text change.

    /**
    * Change In Stock / Out of Stock Text
    */

    add_filter( ‘woocommerce_get_availability’, ‘wcs_custom_get_availability’, 1, 2);
    function wcs_custom_get_availability( $availability, $_product ) {

    // Change In Stock Text
    if ( $_product->is_in_stock() ) {
    $availability[‘availability’] = __(‘Available!’, ‘woocommerce’);
    }

    // Change Out of Stock Text
    if ( ! $_product->is_in_stock() ) {
    $availability[‘availability’] = __(‘Sold Out’, ‘woocommerce’);
    }

    return $availability;

    It says “simply add the following code to the ‘custom functions’ area of your functions.php file” which I did not see in my functions.php so I added it to the end of the file and passed an error several times – wrapping it in <?php ?> didn’t work either. It would be really helpful if you could tell me which line to add it to in the functions.php file.

    Cheers!

    Isaac

    #126111
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Are you using the child theme? If so add it to your functions.php file between

     <?php
    
    ?>

    – Kyle

    #126231
    eyedhaas
    Member
    Post count: 5

    Thanks for getting back to me, Kyle.
    I am not using a child theme – and when I tried adding the code in my functions.php as suggested above, the site crashed and had to reload the functions.php file via FTP.
    Is there a specific line # in the functions.php file where the code snippet should be inserted? woocommerce said to put it in the customs section of the functions.php file but I did not see that section in my file.
    Thanks for the assistance.

    Isaac

    #126234
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    That’s because you are missing a closing bracket after this line

      
    return $availability;
    

    it should be like this

    
    return $availability;
    }
    

    Add it at the bottom before the last ?>
    Give it a try.

    -Rui

    #126236
    eyedhaas
    Member
    Post count: 5

    Yes, that worked. Obviously, I wasn’t paying close attention.
    Thanks!

    Isaac

    #126238
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Thanks Rui

    – Kyle

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register