Woocommerce | Modify backorder message ( single product and cart )
For single product, add this in fuction.php in your theme folder and change the text ‘Please allow 20 days for delivery of this item’:
/* backorder text on single product page */ function so_42345940_backorder_message( $text, $product ){ if ( $product->managing_stock() && $product->is_on_backorder( 1 ) ) { $text = __( 'Please allow 20 days for delivery of this item', 'your-textdomain' ); } return $text; } add_filter( 'woocommerce_get_availability_text', 'so_42345940_backorder_message', 10, 2 );
For “Cart” page, add this in fuction.php in your theme folder and chaneg text ‘Please allow 20 days for delivery of this item ‘:
/* Backorder text on cart page */ function alt_message() { return '<p class="backorder_notification backorder_notification_custom">Please allow 20 days for delivery of this item</p>'; } 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);
and this in your syle.css
.backorder_notification{ display: none; } .backorder_notification_custom{ display: block; margin-bottom:0px; }
If you have a multi language website, you find each string in “String translation”
that’s all