-2

Hi i just installed a wordpress plugin called, WooCommerce Custom Currencies to convert my paypal unsupported currency into USD. The issue is, in the checkout once i choose paypal gateway it shows an error which is, The link you have used to enter the PayPal system contains an incorrectly formatted item amount

The items are in rupees and when it converts to USD, if the conversion is 0.000 it would show the above result. If the result is two decimal places it would proceed successfully. Can anyone help me to roundup the final out come of the checkout(total of the added products).

Manoj Masakorala
  • 446
  • 1
  • 6
  • 20
  • 1
    Here you go http://stackoverflow.com/questions/4483540/php-show-a-number-to-2-decimal-places – DaMaGeX Jan 04 '16 at 17:35
  • I am using wordpress and im quite new to wordpres. I dont know which file i should change. Does rounding happens in woocommerce pulgin files ? – Manoj Masakorala Jan 04 '16 at 17:45

1 Answers1

1

Found the fix to the issue. Has posted originally By sinesiopaco,His answer is as follows which fit me perfectly.

I found a bug on code on conversion. When I try to do payment , it converts to USD using the conversion rate propely but Paypal returns this error:

"The link you have used to enter the PayPal system contains an incorrectly formatted item amount."

But it is a simple trick to fix this. Thus paypal only accept amounts with 2 decimal places. So you can correct you code with a round function as per below:

***FIX: On file woocommerce-custom-currencies/woocommerce-custom-currencies.php, go to function apply_conversion( $paypal_args ) {

Replace from:

$paypal_args[ $key ] = $value * floatval( $conversion_rate );

to:

$paypal_args[ $key ] = round($value * floatval( $conversion_rate ),2);

That's it :)

Manoj Masakorala
  • 446
  • 1
  • 6
  • 20