load discount title while get discount info of a product

Load discount title while get discount info of a product

add_filter('advanced_woo_discount_rules_discount_prices_of_product', function ($discount_prices, $product, $quantity, $cart_item){
    if(!empty($discount_prices['total_discount_details'] && class_exists('\Wdr\App\Controllers\DiscountCalculator'))){
        $rules = \Wdr\App\Controllers\DiscountCalculator::$rules;
        foreach ($discount_prices['total_discount_details'] as $key => $values){
            if(!empty($values)){
                foreach ($values as $rule_id => $discount_info){
                    if(isset($rules[$rule_id])){
                        $discount_prices['total_discount_details'][$key][$rule_id]['rule_title'] = $rules[$rule_id]->rule->title;
                    }
                }
            }
        }
    }
    return $discount_prices;
}, 10, 4);