Display Custom Backorder Wording In WooCommerce

I think as a self-taught developer, tinkerer, or whatever you label yourself, the ability to find the information you need for specific coding solutions is the super-ninja skill. That’s what I do when I learn to solve WooCommerce and Shopify solutions I read about in Facebook groups and other online forums. In this post, we will see how to rephrase the display message for Products available for Backorder.

Custom WooCommerce and Shopify Solutions

Discover useful WooCommerce and Shopify custom solutions for your online store today at affordable prices!


Note: All examples in this post are part of a development/learning WooCommerce install using a default Storefront theme. PHP code is placed in the child theme’s function.php file.


Code, content, and community for developers.

The LAMP stack and the PHP technologies and frameworks it runs.

Image by Mohamed Hassan from Pixabay 

I have this default Backorder message for a Single Product that is out of stock and is marked available for backorder:

With the code snippet below, we can rephrase the ‘Available on backorder‘ message (and others):

add_filter( 'gettext', 'woo_custom_backorder_string_message', 999, 3 );

function woo_custom_backorder_string_message( $translated, $untranslated, $domain ) {

if ( ! is_admin() && 'woocommerce' === $domain ) {

switch ( $translated ) {

case 'Available on backorder':

$translated = 'Can be backordered and ships when stock levels replenish';
break;
}
}
return $translated;
}

A couple of pointers about the code:

  • The ! is_admin() function in the if() conditional ensures nothing on the backend (admin) section changes.
  • The ‘woocommerce’ === $domain applies to the WooCommerce plugin

As shown in the following screenshot, the custom display message is available on the Single Product page for this product:


Do you have a need for this exact customization for your WooCommerce online store? Consider hiring me to complete this for you, hassle-free. Contact me for more information.


Credit Resources

I am so grateful for all of the fantastic resources and content available online. This article is an example of those I studied in order to solidify these concepts: https://www.businessbloomer.com/translate-single-string-woocommerce-wordpress/


If you see any mistakes in the code or know of a better solution, please share them freely in the comments section.


Thank you for reading this post. Please share it with someone else who would enjoy it as well.


Disclaimer: The majority of examples in this post, are performed in a personal development/learning workstation environment and should not be considered production quality or ready. Your particular goals and needs may vary. Like always, just because you can do something doesn’t mean you should. My opinions are my own.

More ways I can help

  • Need hosting for your next web application or WordPress site? I highly recommend Hostinger and use them to host my niche bass fishing site. The service is second to none.
  • Desktop and mobile wallpapers, digital downloads, photography services, Shopify and WooCommerce customizations, and content writing – all in one E-commerce Shop. Find your next digital purchase today!
  • Take your Laravel applications next level with Battle Ready Laravel by Ash Allen. Learn how to improve the performance, maintainability, and security of your Laravel projects in this e-book.

Disclosure: Some of this blog post’s services and product links are affiliate links. At no additional cost to you, should you make a purchase by clicking through one of them, I will receive a commission.

Code, content, and community for developers.

The LAMP stack and the PHP technologies and frameworks it runs.


📰 OpenLampTech has sponsorship opportunities for your brand, product, or service in the weekly newsletter. As an independent publication, collaboration is very affordable.


Hey thanks for commenting! Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.