WPSlash

Set None as Default to Delivery Time and Uncheck Default Order Type

Monday February 15, 2021
add_action("wp_footer", function()

{
	global $woocommerce;
	if(is_checkout())
	{



		?>
		<script>
			jQuery(document).ready(function()

			{


				jQuery('.woofood_order_type input').removeAttr('checked');
				jQuery('#woofood_time_to_deliver').prepend('<option value="0">Please select a time</option>');
				jQuery('#woofood_time_to_pickup').prepend('<option value="0">Please select a time</option>');


			});
		</script>

		<?php
	}	   
});

add_action("woocommerce_checkout_process", "wpslash_check_time_order_checked", 99, 0);

function wpslash_check_time_order_checked()

{

	if(!isset($_POST["woofood_order_type"]))
	{
			wc_clear_notices();

		wc_add_notice("Please select Delivery or Pickup", "error");
	}

	$order_type = isset($_POST["woofood_order_type"]) ? $_POST["woofood_order_type"] : "";



	if( (isset($_POST["woofood_time_to_deliver"]) || $_POST["woofood_time_to_deliver"] ="0"  ) && $order_type =="delivery")
	{
					wc_clear_notices();

		wc_add_notice("Please select a time for delivery", "error");
	}
	if( (isset($_POST["woofood_time_to_pickup"]) || $_POST["woofood_time_to_pickup"] ="0") && $order_type =="pickup")
	{
					wc_clear_notices();

		wc_add_notice("Please select a time to pickup", "error");
	}




} 

Leave a Comment

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

Related Articles

Tutorials

How to Secure Your WooCommerce Restaurant Website: WordPress Security Checklist for 2025

Running a restaurant website isn’t like running a blog. When your site goes down at 7 PM on a Friday, you’re not losing pageviews — you’re losing actual dinner orders, frustrated customers, and the trust you spent years building. And unfortunately, restaurant sites running WooCommerce have become a favorite playground for attackers in 2024 and […]
May 17, 2026
Tutorials

How to Set Up SMS and WhatsApp Order Notifications for Your WooCommerce Restaurant (2026)

Why SMS and WhatsApp Notifications Matter for Restaurant Orders A customer places an order on your <a href="https://www.wpslash.com/how-to-set-up-real-time-order-tracking-for-your-woocommerce-restaurant-website-2025-2/" title="How to Set Up Real-Time Order Tracking for Your <a href="https://www.wpslash.com/how-to-set-up-catering-and-large-group-orders-on-your-woocommerce-restaurant-website-2025/" title="How to Set Up Catering and Large Group Orders on Your WooCommerce Restaurant Website (2025)”>WooCommerce Restaurant Website (2025)”>restaurant website at 7:15 PM during the Friday rush. […]
May 3, 2026
Tutorials

How to Set Up Real-Time Order Tracking for Your WooCommerce Restaurant Website (2026)

Why Real-Time Order Tracking Matters for Restaurant Websites Picture this: a hungry customer places an order on your <a href="https://www.wpslash.com/how-to-build-a-customer-loyalty-program-for-your-wordpress-restaurant-website-2025/" title="How to Build a Customer Loyalty Program for Your <a href="https://www.wpslash.com/how-to-connect-your-wordpress-restaurant-website-to-doordash-uber-eats-grubhub-2025/" title="How to Connect Your WordPress <a href="https://www.wpslash.com/how-to-rank-your-restaurant-website-on-google-local-seo-for-wordpress-2025/" title="How to Rank Your Restaurant Website on Google: Local SEO for WordPress (2025)”>Restaurant Website to DoorDash, Uber […]
May 3, 2026