• Resolved haidermaa

    (@haidermaa)


    Hello!

    I would like to know how can i change the text of Available on Backorder Text for All Backordered Products to “Available For Pre-Order”

    Please see screenshot for your reference.

    https://ibb.co/D9WM5KD

    Looking forward to your reply!

    Sincerely,

    Hayder

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @haidermaa,

    We have support documentation on modifying WooCommerce text strings here: https://docs.woocommerce.com/document/woocommerce-localization/#section-5

    I hope that helps!

    Thread Starter haidermaa

    (@haidermaa)

    Hi!

    Thanks for your prompt reply!

    Is there any other way to do it perhaps through a custom Code Snippet other than translations?

    Looking forward to your reply!

    Sincerely,

    Hayder

    Hi @haidermaa

    It looks like this article (https://woosnip.com/snips/change-backorder-text/) could meet your requirement.

    Thread Starter haidermaa

    (@haidermaa)

    Hi @maykato

    Thanks for your reply!

    I have tried that code but it doesn’t seem to work on my end.

    I have something that i couldn’t understand in the code probably its why it doesn’t work.

    function change_backorder_message( $text, $product ){
        if ( $product->managing_stock() && $product->is_on_backorder( 1 ) ) {
            $text = __( 'Available on Pre-Order', 'your-textdomain' );
        }
        return $text;
    }
    add_filter( 'woocommerce_get_availability_text', 'change_backorder_message', 10, 2 );

    What is your ‘your-textdomain’ & what does it refer to? Do i need to modify that?

    Looking forward to your reply!

    Sincerely,

    Hayder

    Plugin Support Shohan Hossain Nabil – a11n

    (@sohanhossain)

    Hello @haidermaa,

    The following code seems to be working perfectly:

    
    function alt_message() {
      return "This item may take 3-4 weeks to deliver";
    }
    
    function backorder_text($availability) {
    $altmessage = alt_message();
    foreach($availability as $i) {
    $availability = str_replace('Available on backorder', $altmessage, $availability);
    }
    return $availability;
    } 
    add_filter('woocommerce_get_availability', 'backorder_text');
    
    function woocommerce_custom_cart_item_name( $_product_title, $cart_item, $cart_item_key ) {
    $altmessage = alt_message();
      if ( $cart_item['data']->backorders_require_notification() && $cart_item['data']->is_on_backorder( $cart_item['quantity'] ) ) {
    $_product_title .=  __( ' - '. $altmessage, 'woocommerce' ) ;
    }
    return $_product_title;
    }
    add_filter( 'woocommerce_cart_item_name', 'woocommerce_custom_cart_item_name', 10, 3);
    
    

    Source: northmore

    Thanks!

    Thread Starter haidermaa

    (@haidermaa)

    @sohanhossain Worked like a charm!

    Thank you so much!

    Plugin Support Shohan Hossain Nabil – a11n

    (@sohanhossain)

    Great! Thanks for letting us know.

    if you have any further questions, you can start a new thread.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to change the text of “Available On Backorder”?’ is closed to new replies.