Re-Enable Disabled Products on WooFood Once a day

The following snippet will create a scheduled cron to run once a day and re-enable all products .



add_action("init", "schedule_daily_reset_wpslash");

function schedule_daily_reset_wpslash()
{
	if(!wp_next_scheduled('re_enable_products_every_day'))
	{
			wp_schedule_event( strtotime('05:20:00'), 'daily', 're_enable_products_every_day' );

	}

}
add_action("re_enable_products_every_day", "re_enable_products_every_day");

function re_enable_products_every_day()
{
	
	global $woocommerce;
	$all_products = wc_get_products(array("limit"=>-1, 'return'=>'ids' ));
	
	foreach($all_products as $product_id)
	{
		update_post_meta($product_id, 'woofood_product_availability', false);
	}
}