Last active
August 10, 2021 05:55
-
-
Save Balakrishnan-flycart/bf59c6de984f646b33d8606a274b735d to your computer and use it in GitHub Desktop.
Woo Discount Rules v2 - Check Rule is enabled or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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