{"id":54970,"date":"2020-01-17T21:42:40","date_gmt":"2020-01-17T20:42:40","guid":{"rendered":"https:\/\/samuelchopard.ch\/wiki\/?p=54970"},"modified":"2020-01-24T16:21:31","modified_gmt":"2020-01-24T15:21:31","slug":"modify-backorder-message-single-product-and-cart","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/modify-backorder-message-single-product-and-cart\/","title":{"rendered":"Modify backorder message (single product and cart )"},"content":{"rendered":"<p><!--more--><br \/>\nPaste the following code in functions.php:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">\/* backorder text on single product page *\/\r\nfunction so_42345940_backorder_message( $text, $product ){\r\n  if ( $product-&gt;managing_stock() &amp;&amp; $product-&gt;is_on_backorder( 1 ) ) {\r\n      $text = __( 'Please allow 20 days for delivery of this item', 'your-textdomain' );\r\n  }\r\n  return $text;\r\n}\r\nadd_filter( 'woocommerce_get_availability_text', 'so_42345940_backorder_message', 10, 2 );\r\n\r\n\/* Backorder text on cart page *\/\r\nfunction alt_message() {\r\n  return '<\/pre>\n<p class=\"backorder_notification backorder_notification_custom\">Please allow 20 days for delivery of this item<\/p>\n<p>&#8216;; } function backorder_text($availability) { $altmessage = alt_message(); foreach($availability as $i) { $availability = str_replace(&#8216;Available on backorder&#8217;, $altmessage, $availability); } return $availability; } add_filter(&#8216;woocommerce_get_availability&#8217;, &#8216;backorder_text&#8217;); function woocommerce_custom_cart_item_name( $_product_title, $cart_item, $cart_item_key ) { $altmessage = alt_message(); if ( $cart_item[&#8216;data&#8217;]-&gt;backorders_require_notification() &amp;&amp; $cart_item[&#8216;data&#8217;]-&gt;is_on_backorder( $cart_item[&#8216;quantity&#8217;] ) ) { $_product_title .= __( &#8216; &#8211; &#8216;. $altmessage, &#8216;woocommerce&#8217; ) ; } return $_product_title; } add_filter( &#8216;woocommerce_cart_item_name&#8217;, &#8216;woocommerce_custom_cart_item_name&#8217;, 10, 3);<\/p>\n<p>Paste the following in Appearance &gt; Customise &gt; Additional CSS:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">.backorder_notification{\r\n    display: none;\r\n}\r\n.backorder_notification_custom{\r\n    display: block;\r\n    margin-bottom:0px;\r\n}<\/pre>\n<p>Source: <a target=\"_blank\" href=\"https:\/\/www.choosepizzi.net\/woocommerce-modify-backorder-message-single-product-and-cart\/\">https:\/\/www.choosepizzi.net\/woocommerce-modify-backorder-message-single-product-and-cart\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Paste the following code in functions.php: \/* backorder text on single product page *\/ function so_42345940_backorder_message( $text, $product ){ if [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[369,370,327],"class_list":["post-54970","post","type-post","status-publish","format-standard","hentry","category-woocommerce","tag-back-order","tag-message","tag-woocommerce"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/comments?post=54970"}],"version-history":[{"count":2,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54970\/revisions"}],"predecessor-version":[{"id":54979,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54970\/revisions\/54979"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=54970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=54970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=54970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}