Friday, May 24, 2013

Woo-commerce Set the Pay Pal Exchange Rate While converting from one currency to another

Below is the code to set the exchange rate in PayPal while converting from INR Currency to USD

add_filter('woocommerce_paypal_args', 'convert_INR_to_USD');
function convert_INR_to_USD($paypal_args){
 if ( $paypal_args['currency_code'] == 'INR'){
  $convert_rate = 53; //set the converting rate
  $paypal_args['currency_code'] = 'USD'; //change INR 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;
}

No comments:

Post a Comment