Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Balakrishnan-flycart/bf59c6de984f646b33d8606a274b735d to your computer and use it in GitHub Desktop.
Save Balakrishnan-flycart/bf59c6de984f646b33d8606a274b735d to your computer and use it in GitHub Desktop.
Woo Discount Rules v2 - Check Rule is enabled or not
if ( class_exists('\Wdr\App\Controllers\ManageDiscount')) {
$manage_discount = new \Wdr\App\Controllers\ManageDiscount();
$rules = $manage_discount->getDiscountRules();
foreach ($rules as $rule){
//loop
//$rule->getRuleDiscountType() ->it will return discount type
//array(1,2) -> change your rule id instead of 1,2
//$timestamp -> boolean (true or false)
//$rule->getStartDate($timestamp = false, $format = "Y-m-d H:i:s") -> You can get start date in timestamp or dateformat
//$rule->getEndDate($timestamp = false, $format = "Y-m-d H:i:s") -> You can get end date in timestamp or dateformat
if($rule->getRuleDiscountType() == 'wdr_free_shipping' && in_array($rule->getId(),array(1,2)) && $rule->isEnabled()){
//action required if condition passed
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment