/** * Converts an amount from one currency to another, using the Aelia Currency * Switcher. * * @param double amount The amount to convert. * @param string to_currency The target currency. * @param string from_currency The source currency. * @return double */ function aelia_convert_amount_to_currency($amount, $to_currency, $from_currency) { // Call the currency conversion filter. return apply_filters('wc_aelia_cs_convert', $amount, $from_currency, $to_currency); } /** * Converts the payments passed to Payeezy to USD. * * @param array request_data The data used for a payment request. * @param object A paument request instance. * @return array The payment data, with the amount in USD. * @author Aelia * @link https://bit.ly/aelia_codeable */ add_filter( 'wc_first_data_payeezy_gateway_request_data', function($request_data, $payment_request) { if(strtoupper($request_data['currency_code']) != 'USD') { $request_data['amount'] = round(aelia_convert_amount_to_currency($request_data['amount'], 'USD', $request_data['currency_code']), 2); } return $request_data; }, 10, 2);