WooCommerce: Show Dispatch / Est. Shipping Date @ Single Product

A good way to inform online customers and avoid issues is showing the estimated delivery / dispatch time on the single product page, just below the “Add to Cart” button. Yes, you could do that manually by adding shipping info to each product short description, but the goal of Business Bloomer is to learn how to code that instead, so you won’t need to write things manually.

Also, this is great because if you change something in your dispatch rules, you just need to change the short PHP snippet and not all your product descriptions. It’s much more flexible this way.

Finally, in this post we’ll learn how to work with cut-off times (hour of the day) and current day of the week (pure PHP), so that we can show a “dynamic” notice based on current date. So, let’s see how it’s done!

It’s Monday before 4PM – this snippet is printing a notice just below the single product page add to cart that if I order by 4PM the product will be shipped today!

PHP Snippet: Display Dispatch / Estimated Delivery Date @ Single Product Page

Case scenario:

  • Friday/Saturday/Sunday orders ship on Monday
  • For other days, if before 4PM ships today…
  • …if after 4PM ships tomorrow

Please note the “date(‘N’)” and the “date(‘H’)” functions, which in PHP they respectively give me the current day of the week and current hour of the day so I can compare them with local & current time. Also look into “date_default_timezone_set()” function in case you want to set a different timezone, which is vital for this snippet’s calculations.

 * @snippet       Dispatch Date @ WooCommerce Single Product
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.9
 * @donate $9     https://businessbloomer.com/bloomer-armada/

add_action( 'woocommerce_after_add_to_cart_form', 'bbloomer_dispatch_info_single_product' );
function bbloomer_dispatch_info_single_product() {
	date_default_timezone_set( 'Europe/London' );  
	// if FRI/SAT/SUN delivery will be MON
	if ( date( 'N' ) >= 5 ) {
		$del_day = date( "l jS F", strtotime( "next monday" ) );
		$order_by = "Monday";
	// if MON/THU after 4PM delivery will be TOMORROW
	elseif ( date( 'H' ) >= 16 ) {
		$del_day = date( "l jS F", strtotime( "tomorrow" ) );
		$order_by = "tomorrow";
	// if MON/THU before 4PM delivery will be TODAY
	else {
		$del_day = date( "l jS F", strtotime( "today" ) );
		$order_by = "today";

	$html = "<br><div class='woocommerce-message' style='clear:both'>Order by 4PM {$order_by} for delivery on {$del_day}</div>";
	echo $html;

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials. You can start learning how to customize WooCommerce without unnecessary plugins. Watch me code and learn by example!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

10 thoughts on “WooCommerce: Show Dispatch / Est. Shipping Date @ Single Product

  1. hello,
    thank you for the good job you are doing. Can the the js code show date rang like ‘ order today for delivery in 3 – 5 days, date.

    1. Hey Jay, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. Hi

    I want to ask, what if I want to tell the customer the lead time like this: please allow 2-3 business days to processing

    I want to put it under the Add to Cart ”button


    1. Hi Rodolfo how can I implement this rule in a woocommerce in Spanish, the result that I choose as is in English

      1. Did you try changing the text to Spanish inside the snippet?

        1. yes i even replaced
          date_default_timezone_set (‘Europe / London’); by date_default_timezone_set (‘Europe / Madrid’) ;.
          It does not respond, it continues giving months and days in English, also “place your order before 4pm today and receive it today, it is not possible. Thank you for your help.

          1. Oh I see what you mean. You’re talking about date “format”, not Spanish words. Check https://www.php.net/manual/en/function.date.php

            1. Hi Rodolfo,

              First of all, thank you for your great work, information, sharing and caring!

              Again, great snippet! Wouldn’t it be great if you can have a in stock or on backorder dependency build-in?
              Any suggestions how?



              1. It’d be great, yes – but unfortunately it’s custom work

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

Your email address will not be published. Required fields are marked *