<?php

namespace CouponsPlus\App\Handlers;

use CouponsPlus\Original\Events\Handler\EventHandler;
use WC_Shipping_Rate;

#[\AllowDynamicProperties]
Class ShippingDiscountLabelPrinterHandler extends EventHandler
{
    protected $numberOfArguments = 1;
    protected $priority = 10;

    public function execute()
    {
        add_filter('woocommerce_cart_shipping_method_full_label', function(string $label, WC_Shipping_Rate $shippingRate) : string {
            (array) $meta = $shippingRate->get_meta_data();

            if (isset($meta['cp_original_cost']) && $meta['cp_original_cost']) {
                $label .= ' <del class="cp-shipping-original" aria-hidden> '.wc_price($meta['cp_original_cost']).'</del>';
            }

            return $label;
        }, $priority = 10, $numberOfArguments = 2);   
    }
}