Documentation

Change The Date Or Time Slot Format On An Order

The code in this article requires WooCommerce Delivery Slots v1.7.7+

It’s possible to change or modify the date and time slot content which is displayed in the admin or to the customer after placing an order.

Delivery details for customer

You can add any of the code given to your child theme’s functions.php file, or using the Code Snippets plugin.

Change the Delivery Date display

To change the date display, we will use the iconic_wds_date_display filter.

We can use PHP’s date() function to reformat the date like so:

/**
 * Change date display.
 *
 * @param string $date
 * @param array  $date_time
 *
 * @return string
 */
function iconic_change_date_display( $date, $date_time ) {
	if ( is_admin() ) {
		return $date;
	}

	if ( empty( $date_time['timestamp'] ) ) {
		return $date;
	}

	return date( 'l jS F, Y', $date_time['timestamp'] );
}

add_filter( 'iconic_wds_date_display', 'iconic_change_date_display', 10, 2 );

Firstly, we’re checking if we’re on an admin page. if we are, we return the date in its normal format. Then we check if the timestamp parameter is set. If it isn’t, we again return the date as normal. Finally, we use PHP’s date() function to change the format of our date.

The date/time display will now look like this:

example of time and date

Change the Time Slot display

To change the date display, we will use the iconic_wds_time_display filter.

/**
 * Change time display.
 *
 * @param string $time
 * @param array  $date_time
 *
 * @return string
 */
function iconic_change_time_display( $time, $date_time ) {
	return $time;
}

add_filter( 'iconic_wds_time_display', 'iconic_change_time_display', 10, 2 );

You can modify the returned $time string however you see fit.

Are you using WooCommerce Delivery Slots yet?

Start your 14-day free trial right now and get instant access to the features described in this article.

or learn more

Was this helpful?

Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.

WooCommerce Delivery Slots

WooCommerce Delivery Slots

Not got the plugin yet? Get instant access right now, free for 14 days.

or learn more

Still need help?

If you haven't found what you're looking for in our documentation, please contact support.

Get Support