Get the discount info of current line item and the applied rule title in cart page

Retrieve discount information and rule titles for line items on the cart page.

add_action('woocommerce_before_cart', function (){
    if(class_exists('\Wdr\App\Router') && class_exists('Wdr\App\Controllers\DiscountCalculator')){
        $manage_discount = \Wdr\App\Router::$manage_discount;
        $applied_rules = \Wdr\App\Controllers\DiscountCalculator::$applied_rules;
        foreach ($applied_rules as $applied_rule) {
            $rule_title = $applied_rule->rule->title;
            //Here you get the applied rules info
        }

        if (!WC()->cart->is_empty()){
            foreach (WC()->cart->cart_contents as $item){
                if(isset($manage_discount::$calculated_cart_item_discount[$item['key']])){
                    $discount_info_of_current_line_item = $manage_discount::$calculated_cart_item_discount[$item['key']];
                    //Here you get the discount info of current line item
                }
            }
        }
    }
});