• Resolved desitop

    (@desitop)


    Hi, 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 allow 15-20 days for delivery.”

    Please see the screenshot for your reference.

    https://ibb.co/D9WM5KD

    I can see that @sohanhossain answered this question already, but I am not experienced with coding, so I wanted to ask where to add this code without messing my whole website. If it is possible, I’d like to know how to make the text stand out (color, bold letters, etc.)

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

    Looking forward to your reply!

    Kind regards, Desislava

Viewing 2 replies - 1 through 2 (of 2 total)
  • @desitop

    You can add custom functions using a child theme or the code snippets plugin

    Thread Starter desitop

    (@desitop)

    Thanks much appreciated. I fixed it with this code

    function alt_message() {
      return "AVAILABLE ONLY FOR PRE-ORDER. Please note that this item may take 2-3 weeks to ship.";
    }
    
    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);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom text on backorders’ is closed to new replies.