MakeMeHappy.sk
SK EN
All snippets

How to Display a Custom Notification for a Made-to-Order Product

For a simple, made-to-order physical product, you can add a short sentence prompting the customer to check the delivery date before making a purchase. The following mini-plugin will add it to the standard product summary. The original text regarding stock availability will remain visible.

Scope of verification: The code has been verified against the WooCommerce 11.2.1 source code, passed syntax checks in PHP 8.4, and undergone isolated tests. It has not been tested in a live WordPress environment, either within a theme or in a browser. Before using it, please test it on a test copy of your specific e-commerce site.

When the notification appears

Only for a specific, simple, physical, and non-downloadable product that WooCommerce considers purchasable and in stock, and for which is_on_backorder(1) It returns a positive result. We are therefore checking the availability of a single item. Allowing backorders when there is remaining inventory does not, in and of itself, trigger a notification.

When set to manual mode on backorder WooCommerce treats a product as a made-to-order item even if the quantity is not tracked. Therefore, the code does not add a separate condition backorders_allowed(), which could prevent such a manual state. The behavior is based on methods of the official WC_Product class.

The complete code for the custom plugin

Name the file mmh-backorder-notice.php. The prefix mmh_bo_notice_20261028_ Keep it enabled both when the function is running and when registering the hook. Do not install the same code in multiple locations at the same time.

<?php
/**
 * Plugin Name: MMH – Upozornenie na tovar na objednávku
 * Description: Doplní upozornenie na detaile jednoduchého fyzického produktu na objednávku.
 * Version: 1.0.0
 * Requires PHP: 7.4
 * License: GPL-2.0-or-later
 */

defined( 'ABSPATH' ) || exit;

add_action( 'woocommerce_single_product_summary', 'mmh_bo_notice_20261028_render', 25 );

/**
 * Render a plain notice; leave purchasing and the original stock text unchanged.
 */
function mmh_bo_notice_20261028_render() {

	if ( ! class_exists( 'WC_Product' ) || ! function_exists( 'is_product' ) || ! is_product() || is_admin() ) {
		return;
	}

	global $product;

	if (
		! $product instanceof WC_Product
		|| ! $product->is_type( 'simple' )
		|| $product->is_virtual()
		|| $product->is_downloadable()
		|| ! $product->is_purchasable()
		|| ! $product->is_in_stock()
		|| ! $product->is_on_backorder( 1 )
	) {
		return;
	}

	echo '<p class="mmh-bo-notice-20261028">' . esc_html( 'Tovar je na objednávku. Pred nákupom si u nás overte dostupnosť a predpokladaný termín odoslania.' ) . '</p>';
}

Installation via a custom small plugin

  1. Create a folder on your computer mmh-backorder-notice and save the file mentioned above to that location mmh-backorder-notice.php in UTF-8. The file must begin with <?php, with no text before it and no closing PHP tag.
  2. Compress the entire folder into a ZIP file. The structure should be mmh-backorder-notice/mmh-backorder-notice.php; do not include tests or research materials in the ZIP file.
  3. First, open the following on the test website: Plugins → Add New → Upload a Plugin, upload the ZIP file and activate it MMH – Notice Regarding Items Available by Special Order.
  4. Check for simple made-to-order products, in-stock products, and sold-out products. You should only expect a warning in the first case. Also check for products without a price and products of the wrong type.
  5. View the details as an unregistered visitor on both mobile and desktop. If the website uses a cache, refresh the relevant product page. If you're using a different theme or have changed it, run the check again.

This notice intentionally does not include a fictitious delivery date. You can customize the wording in a single text message esc_html(). Keep the quotation marks and use plain text without HTML. The output escaping is explained WordPress reference for esc_html().

Restrictions You Need to Know

  • Variable, group, external, and other types of products are excluded. The code does not respond to a change in the selected variation. For a group product, the note may not appear until a separate single product is opened.
  • Virtual and downloadable products are excluded, even though they use the type simple. Similarly, nothing will be displayed if a product is missing or if WooCommerce does not consider the product to be purchasable.
  • It is designed for a classic PHP template, which calls woocommerce_single_product_summary. Priority 25 is located in the standard template between the short description and the purchase form. The theme may change this order. We do not guarantee that this will be displayed in the Single Product block template or in the page builder without this hook; an empty result is not a reason to modify the shopping cart.
  • It does not check the currently selected quantity or the contents of the shopping cart. If there are three items in stock and a request for five, a note with this code will not appear dynamically. It is not the only source of information about availability; keep the appropriate standard WooCommerce notifications.
  • It does not calculate dates, synchronize suppliers, or save data. It does not track changes to the shopping cart, prices, orders, or payments, and it does not send emails. When WooCommerce is disabled, it does not produce any output.
  • The text is strictly in Slovak. The mini-plugin does not add translation messages or custom styles. Check your website's settings to ensure multilingual display and readability.

The hook used and the standard order are in the official WooCommerce product template. This code adds a separate paragraph, so it may appear alongside the original notice. Please make sure that the two texts do not contradict each other in meaning.

How to turn off the feature

In the list of plugins, deactivate MMH – Notice Regarding Items Available by Special Order and refresh the product page cache as needed. The additional paragraph will no longer be generated; this does not change the product's inventory settings. If editing the custom text causes an error and you cannot access the admin panel, use your hosting file manager or SFTP to rename only the folder wp-content/plugins/mmh-backorder-notice. You don't need to modify the WooCommerce core files or the theme.

If you also need an estimated date

The additional sentence only explains availability. For dates, see documentation of the estimated delivery time a the relevant plugin. You can find additional minor changes in "Snippets" section.