Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Balakrishnan-flycart/ae8433829f248ff5d75dfc0c794dcc6a to your computer and use it in GitHub Desktop.
Save Balakrishnan-flycart/ae8433829f248ff5d75dfc0c794dcc6a to your computer and use it in GitHub Desktop.
Woo Discount Rules v2 - Get rules start date and end date
if ( class_exists('\Wdr\App\Controllers\ManageDiscount')) {
$rules = \Wdr\App\Controllers\ManageDiscount::$available_rules;
$start_date = $end_date = array();
if(!empty($rules) && is_array($rules)){
foreach ($rules as $rule){
if($rule->rule->enabled == 1){
$rule_id = $rule->rule->id;
//get timestamp
$start_date_timestamp = $rule->rule->date_from;
$end_date_timestamp = $rule->rule->date_to;
//Date format
$format = "Y-m-d H:i:s";
$start_date[$rule_id] = date($format, $start_date_timestamp);
$end_date[$rule_id] = date($format, $end_date_timestamp);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment