Get matched rule info based on product
Get matched rule info based on product
global $product;
$price = $product->get_price();
$discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $price, $product, 1, 0, 'all', true, false);
if($discount !== false){
if(class_exists('\Wdr\App\Controllers\DiscountCalculator')) {
if(isset($discount['total_discount_details']) && !empty($discount['total_discount_details'])){
$rules = \Wdr\App\Controllers\DiscountCalculator::$rules;
$rule_ids = array_keys($discount['total_discount_details']);
foreach ($rule_ids as $rule_id){
if(isset($rules[$rule_id])){
$matched_rule = $rules[$rule_id]->rule; // Here we get the matched rule info
echo "Start date: ".date_i18n("j F, Y", $matched_rule->date_from); // Here we get rule valid from date
echo "End date: ".date_i18n("j F, Y", $matched_rule->date_to); // Here we get rule valid to date
}
}
}
}
}