WPSlash

Make Products Available only on specific days of week

Friday October 23, 2020

Here is an example on how to make products unavailable all the days except from some days depending on the product category.

On the following example we are making the products with Category Name “FANCY MENU” to be available only on Tuesday and Wednesday

You can copy the following code under your functions.php and adjust it to your needs

function wpslash_woofood_enable_product_specific_days( $purchasable, $product ){
	
$product_id =$product->get_id();
	if ( $product->is_type('variation') ){
        $product_id = $product->get_parent_id();
    } 

	
        $terms = get_the_terms( $product_id, 'product_cat' );
	$product_categrories = array();
	foreach ($terms as $term) {
    $product_categrories[] = $term->name;
   
}
if(in_array("FANCY MENU", $product_categrories)  )
{
	if(date('l') =="Tuesday" ||date('l') =="Wednesday" )
	{
			return true;
	}
	else
	{
		return false;


	}

}
	  else
	  {
		  	  return true;


	  }
	 
return true;
}
add_filter( 'woocommerce_is_purchasable', 'wpslash_woofood_enable_product_specific_days', 99, 2 );
add_filter( 'woocommerce_variation_is_purchasable', 'wpslash_woofood_enable_product_specific_days', 99, 2 );

Leave a Comment

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

Related Articles

Tutorials

How to Set Up Local SEO for Your Restaurant Website: A Complete WordPress Guide to Ranking Higher on Google Maps, Local Search, and Driving More Online Orders

Here’s a stat that should grab your attention: 46% of all Google searches have local intent, and “restaurants near me” is consistently one of the top local search queries worldwide. Yet most independent restaurant owners spend their marketing budgets on social media ads while completely ignoring the one channel that drives hungry, ready-to-order customers directly […]
March 28, 2026
Tutorials

How to Set Up and Manage Multiple Restaurant Locations with WordPress and WooCommerce (Complete Guide to Menus, Delivery Zones, and Centralized Order Management)

Why Multi-Location Restaurant Management Matters (And Why Most Plugins Get It Wrong) Running one restaurant is hard enough. Running two, five, or twenty locations — each with its own menu variations, delivery boundaries, pricing quirks, and kitchen staff — is a whole different beast. And when you try to bring all of that online, most […]
March 28, 2026
Tutorials

How to Set Up SMS Order Notifications and Automated Text Message Alerts for Your WooCommerce Restaurant (Complete Guide for Owners, Staff, and Customers)

Running a restaurant means dealing with a constant stream of orders, and every minute counts. When a customer places an order online and doesn’t hear anything back, anxiety kicks in. Did the restaurant get my order? Is it being prepared? When will it arrive? SMS notifications solve this problem instantly — a quick text message […]
March 28, 2026