"Woo Discount: Currency switcher by realmag777 - compatible for price discount on Is multiple allow

Ensure Woo Discount compatibility when multiple is allowed.

if(!function_exists('woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency')){
	function woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency($price){
		global $WOOCS;
		if(isset($WOOCS)){
			if (isset($WOOCS->default_currency) && isset($WOOCS->current_currency)){
				if($WOOCS->default_currency != $WOOCS->current_currency && $WOOCS->is_multiple_allowed){
					$currencies = $WOOCS->get_currencies();
					$price = $price*$currencies[$WOOCS->current_currency]['rate'];
				}
			}
		}
		return $price;
	}
}

add_filter('woo_discount_rules_discount_amount_before_apply', function ($discount, $set, $price, $product_page, $product){
    if(isset($set['amount'])){
        if(isset($set['amount']['product_discount_details'])){
            if(isset($set['amount']['product_discount_details']['discount_type'])){
                $discount_type = $set['amount']['product_discount_details']['discount_type'];
                if($discount_type == 'price_discount'){
					$discount = woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency($discount);
                }
            }
        } else if(isset($set['amount']['price_discount'])){
			$discount = woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency($set['amount']['price_discount']);
		}
    }
    return $discount;
}, 10, 5);

add_filter('woo_discount_rules_table_content_discount_html', function($discount, $discount_type, $to_discount, $value){
    if($discount_type == 'price_discount'){
		$to_discount = woo_discount_rules_discount_amount_before_apply_convert_price_to_current_currency($to_discount);
		$discount = wc_price($to_discount);
    }
    return $discount;
}, 10, 4);