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 a Self-Service Ordering Kiosk for Your Restaurant Using WordPress, WooCommerce, and a Touchscreen Display (Complete Step-by-Step Guide)

Self-service ordering kiosks used to be something only big chains like McDonald’s or Panera could afford. We’re talking $5,000–$15,000 per unit, proprietary software, and expensive maintenance contracts. But here’s the thing — you can build a fully functional self-service kiosk using WordPress, WooCommerce, and a consumer-grade touchscreen display for a fraction of that cost. This […]
March 27, 2026
Tutorials

How to Set Up a Kitchen Display System (KDS) and Receipt Printer Integration with Your WooCommerce Restaurant Ordering Site (Complete Step-by-Step Guide)

What Is a Kitchen Display System (KDS) and Why Every Restaurant Needs One If your kitchen still relies on handwritten tickets or printed slips getting lost under a sauce splatter, it’s time for an upgrade. A Kitchen Display System (KDS) is a digital screen — typically a tablet or monitor — mounted in your kitchen […]
March 27, 2026
Tutorials

How to Set Up a Customer Loyalty and Rewards Program for Your Restaurant Using WooCommerce (Complete Guide to Repeat Orders and Higher Revenue)

Here’s a reality check: acquiring a new customer costs five to seven times more than keeping an existing one. For restaurants running online ordering, that math should change everything about how you think about marketing. A well-designed loyalty program doesn’t just make customers feel good — it creates a predictable revenue engine that grows stronger […]
March 26, 2026