Support » Plugin: WooCommerce » Change “out of stock” text to “previously sold”

  • Resolved patbell101

    (@patbell101)


    Can I change “out of stock” text to “previously sold”?

    and can I order by amount in stock desc or In stock items first?

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @patbell101!

    Can I change “out of stock” text to “previously sold”?

    Yes, you sure can!

    You can either do it using some code: http://wpdecoder.com/php/woocommerce-change-out-of-stock-text/

    OR

    You can use a plugin, like https://wordpress.org/plugins/woocommerce-out-of-stock-message/

    If you use the code, please make sure you add it to your site either via a child themes’ functions.php or via a plugin that allows custom code to be added, such as https://wordpress.org/plugins/code-snippets/

    Cheers!

    Great, those snippets work a treat. fwiw the plugin claims to be out of date so to be safe I used code snippets for the code.

    Plugin Support Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @patbell101!

    Awesome! Thanks for letting me know 🙂

    Hi,

    After insterting the code into my site using the code snippet pluggin my site stopped working.

    Error message: “”websitename.net is currently unable to handle this request””

    I have disabled and removed the codes but still my site wont work.
    Here is the code used.

    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;
    }

    Your kind assistance and suggestions would be appreciated.

    Regards

    Plugin Support Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @stonebot

    The problem is that you’ve used the backquote (acute), instead of the single quote, which is '

    Use this:

    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;
    }

    Cheers!

    Hi, thanks for the reply..

    Upon inserting the code, it shows a couple of errors

    parse error : syntax error, unexpected ‘of’ (T_STRING), expecting ‘;’ on line 4
    Parse error: syntac error, unexpected ‘stock’ ……..

    Kindly assist.
    Regards

    Plugin Support Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @stonebot!

    Somehow the single quote still reverted to the backquotes. Sorry about this.

    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;
    }

    See if the above code works now.

    Hi,
    Thanks once again for the support.

    after inserting the code, now my site wont load, error 500.
    Kindly assist

    Error 500 is usually a slow host, especially shared hosting, retrying often solves the issue or look at your error logs and speak to your host,

    Plugin Support Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    patrickhaond

    (@patrickhaond)

    I had the same Error 500 and it was only a matter of quotes !

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.