skip to Main Content

I am using the following code to change the text when products are in stock and out of stock, which works perfectly. But I cannot make it change the backorder text no matter how I adjust the code, it seems to be written over by the existing code.

How would I adjust this snippet to also be able to adjust the backorder tetx to say "5 days delivery, backordered"

add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
function wcs_custom_get_availability( $availability, $_product ) {
    
    // Change text if in stock
    if ( $_product->is_in_stock() ) {
        $availability['availability'] = __('<div class="breadcrumbsstockstatus">På lager</div><div class="breadcrumbsstockinfo">Levering 1-2 hverdage</div>', 'woocommerce');
    }
    // Change text if out of stock
    if ( ! $_product->is_in_stock() ) {
        $availability['availability'] = __('Ikke på lager - kommer igen', 'woocommerce');
    }
    return $availability;
}

Please signup or login to give your own answer.
Back To Top
Search