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 Build a Progressive Web App (PWA) for Your Restaurant Ordering Website: Turn Your WooCommerce Site into a Mobile App Experience (Complete Step-by-Step Guide)

Your customers are already ordering food on their phones. The question is whether your restaurant’s website feels like a clunky webpage or a smooth, app-like experience. Progressive Web Apps (PWAs) bridge that gap — giving your WooCommerce restaurant site the speed, reliability, and engagement of a native mobile app without the hefty development costs or […]
March 29, 2026
Tutorials

How to Integrate Third-Party Delivery Services (DoorDash Drive, Uber Direct, and Stuart) with Your WooCommerce Restaurant Website (Complete Setup Guide)

Running a <a href="https://www.wpslash.com/restaurant-website-ordering-system/" title="Restaurant Website Ordering System: The Ultimate Guide to Effortless Online Orders“>restaurant website on WooCommerce gives you full control over your brand, your menu, and your customer relationships. But there’s always been one nagging challenge: getting the food from your kitchen to the customer’s door without relying on marketplace apps that take […]
March 29, 2026
Tutorials

How to Track Restaurant Orders, Revenue, and Customer Behavior with WooCommerce Analytics and Reporting (Complete Guide to Data-Driven Decisions for Food Businesses)

Why Restaurant Analytics Matter: Understanding the Numbers Behind Every Order Running a restaurant without looking at your data is like cooking without tasting your food. You might get lucky, but you’re probably leaving money on the table — and wasting ingredients in the process. For online food ordering businesses, every click, every abandoned cart, and […]
March 29, 2026