• Resolved supergap

    (@supergap)


    Hi,
    I’m going crazy with ‘Out of stock’ label on sold out product.
    i would like to change them to ‘sold out’. But no way:

    I tried with:
    add_filter( ‘woocommerce_get_availability’, ‘wcs_custom_get_availability’, 1, 2);
    function wcs_custom_get_availability( $availability, $_product ) {
    // Change Out of Stock Text
    if ( ! $_product->is_in_stock() ) {
    $availability[‘availability’] = __(‘Sold Out’, ‘woocommerce’);
    }
    return $availability;
    }

    and other similar codes.
    The origin of the issue it’s probably owned to the Theme (Kloe theme).
    Having a look to its PO language file I can see that the original name in the original source text is ‘Out of stock’. Probably the theme overcome Woocommerce. So probably in Function.php I have to use different code to target Kloe theme. I’m selling woman bags: Out of stock it’s not ok..
    Thanks a lot.

    PS please, why you don’t introduce a setting page to change these labels. Could be greta.

Viewing 3 replies - 1 through 3 (of 3 total)
  •  /**
      * Change Sold Out Text
      */
    function change_text_soldout ( $text, $product) { 
        if ( !$product->is_in_stock() ) {
            $text = __('Sold Out', 'woocommerce'); 
        } 
        return $text; 
    }
    add_filter('woocommerce_get_availability_text', 'change_text_soldout', 10, 2 );

    We haven’t heard back from you in a while, so I’m going to mark this as resolved. Feel free to start a new thread if you have any further questions!

    Hello.
    I have a similar issue, also with the Kloe theme.
    I would like to change to another phrase instead of “out of stock”.
    I tried entering the above mentioned code in the customizer but I just received error warnings. (I am just starting to work with WordPress and WooCommerce..)

    Additional question:
    How can I activate a notification system, that informs customers once the product is back in stock via e-mail?

    Kind regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘change Out of stock label – Function.php code doesn’t work 4 me’ is closed to new replies.