Conditionally Modify the Same/Next Day Cut-off Time Based on Shipping Methods

WooCommerce Delivery Slots has a feature that allows you to modify the same day and next day delivery cut-off. But if you want to have different cut-off times for different shipping methods, you can achieve it with this code snippet.

Use case

If your logistics team takes at least 1 day for the delivery, you might want to disable the same day cut off at the midnight for the Flat rate shipping methods. But you would allow all the local pickup deliveries till the evening.

 * Iconic WDS - Conditionally modify the same/next day cut off time based on shipping methods.
 * @return void
function iconic_conditionally_modify_cutoff_time() {
	global $iconic_wds;

	if ( empty( $iconic_wds ) || empty( WC()->session ) ) {

	$shipping_methods = WC()->session->get( 'chosen_shipping_methods' );

	if ( ! isset( $shipping_methods[0] ) && isset( $_POST['shipping_method'][0] ) ) {

	$shipping_method = isset( $_POST['shipping_method'][0] ) ? $_POST['shipping_method'][0] : $shipping_methods[0];

	// TODO modify the logic as per your requirements.
	if ( false !== strpos( $shipping_method, 'local_pickup' ) ) {
		// For all Local Pickups, allow till 18:00.
		$iconic_wds->settings['datesettings_datesettings_sameday_cutoff'] = '18:00';
		// Set empty for no cut off.
		$iconic_wds->settings['datesettings_datesettings_nextday_cutoff'] = '';
	} else {
		// For other shipping methods, disable at mid night.
		$iconic_wds->settings['datesettings_datesettings_sameday_cutoff'] = '00:00';
add_action( 'wp_loaded', 'iconic_conditionally_modify_cutoff_time', 11 );

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