I need to convert currency from PEN to USD for the Paypal plugin in Woocommerce.
My code below works for converting the price but not the shipping costs:
add_filter('woocommerce_paypal_args', 'convert_bgn_to_eur');
function convert_bgn_to_eur($paypal_args){
if ( $paypal_args['currency_code'] == 'PEN'){
$convert_rate = 3.3; //set the converting rate
$paypal_args['currency_code'] = 'USD'; //change Pen to USD
$i = 1;
while (isset($paypal_args['amount_' . $i])) {
$paypal_args['amount_' . $i] = round( $paypal_args['amount_' . $i] / $convert_rate, 2);
++$i;
}
}
return $paypal_args;
}
How do I also convert the shipping costs of the product?