• Can anyone tell me how I can change the text that shows for a product when I allow backorders?

    It currently says “Available on backorder” but I want to change it to read “Available on backorder – Will ship within 2-3 weeks.”

    Thank you very much for any help you can give.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter harbingers

    (@harbingers)

    I figured this one out. BUT, if you are looking for a solution to this, this is how I changed it.

    First I downloaded and installed the plugin called Code Snippets which is one of the best WordPress tools ever. Then I added a new snippet with this code:

    function backorder_text($available) {
    
    foreach($available as $i) {
    
    $available = str_replace('Available on backorder', 'YOUR NEW TEXT GOES HERE', $available);
    
    }
    
    return $available;
    }
    add_filter('woocommerce_get_availability', 'backorder_text');

    New user here who knows next to nothing about WordPress, not to mention programming in php. I want to change my text to read “Available on backorder, estimate date of arrival is …” To fill in the … I have a custom field in my database that is (I believe) ‘_dateavailable’, which has all the estimated dates of my not-in-stock-yet items. How can I change this, adding in the custom field? Could you give me a step-by-step tutorial for dummies?

    To help others, I wanted to vary the text displayed at product level, some products take longer than others to produce. So in the woocommece product page I created a custom field called “Out_of_stock_message” and in it I put like “Lead time is 2 weeks”.

    Then in my child themes functions.php file I added this…

    add_filter( 'woocommerce_get_availability' , 'revised_woocommerce_get_availability' , 10, 2 );
    
    function revised_woocommerce_get_availability( $available_array , $product) {
    
    if ( $product->managing_stock() ) {
    
      if ( !($product->is_in_stock() && $product->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount' ))  && ($product->backorders_allowed() && $product->backorders_require_notification())  ) {
    
      $custom_meta_value = get_post_meta( $product->id, 'Out_of_stock_message', true );
    	$available_array["availability"] = $custom_meta_value;
       }
    }
    
        return $available_array;
    }

    This only affects the product page, not the cart/basket page. Hope that helps someone.

    @robingb that works perfectly, thank you.

    Is there a way to do this for a custom “Out of Stock” notification for items out of stock and not available on backorder?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Woocommerce – Change "Available on backorder" text’ is closed to new replies.