How to Add Custom Currency and Conversion Rate in WooCommerce

Recently We have developed an WooCommerce store where we needed to use store currency as Indonesia Rupiah. Though the currency is in the list but when we tried to activate Paypal checkout, we saw an error appeared “Gateway Disabled: PayPal does not support your store currency“.  So we had to add custom currency and conversion rate in WooCommerce to resolve this issue. Lets see how you can do this.

At first If we don’t find the desired currency in the drop down list in WooCommerce, then we need to add it and it’s unit as follows:

add_filter( ‘woocommerce_currencies’, ‘add_inr_currency’ ); add_filter( ‘woocommerce_currency_symbol’, ‘add_inr_currency_symbol’ ); function add_inr_currency( $currencies ) { $currencies[‘IDR’] = ‘Indonesia Rupiah’; return $currencies; } function add_inr_currency_symbol( $symbol ) { $currency = get_option( ‘woocommerce_currency’ ); switch( $currency ) { case ‘IDR’: $symbol = ‘Rp ‘; break; } return $symbol; }

In here IDR is the universal symbol for  Indonesia Rupiah. Next we have to add IDR to paypal valid currencies array:

add_filter( ‘woocommerce_paypal_supported_currencies’, ‘add_bgn_paypal_valid_currency’ ); function add_bgn_paypal_valid_currency( $currencies ) { array_push ( $currencies , ‘IDR’ ); return $currencies; }

Finally we need to convert the amount to Paypal supported currency. We have converted it to USD as follows:

add_filter(‘woocommerce_paypal_args’, ‘convert_bgn_to_usd’); function convert_bgn_to_usd($paypal_args){ if ( $paypal_args[‘currency_code’] == ‘IDR’){ $convert_rate = 13125; //set the converting rate $paypal_args[‘currency_code’] = ‘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; }

where we set the conversion rate 13125. And here is the outcome:

Custom-Currency-WooCommerce

Custom-Currency-WooCommerce1

187414-429091-419x582-freeebookonblogsetupwordpress

Get This Free eBook & Turn Your Abandoning Visitors into Customers

Attracting potential visitors is hard enough for every blogger but

grabbing their interest and retaining then is even more difficult for so many reasons.

Get this Amazing FREE eBook to learn the tricks to Beautify Your WordPress Blog.

It also has 300+ essential wordpress plugin lists.

Please check your inbox. And also don\'t forget to Check Spam box.

[wpdreams_rpp id=0]
  • Ccant

    Great Guys! thanks!! but, may i ask, where exactly do i add that lines??? my currency does appear and my country´s symbol is universal symbol for money, so whats lef for me to do is to add the convertion to USD? if that is in the case, where to add the code is my question.
    Thanks great tips by the way!!

187414-429091-419x582-freeebookonblogsetupwordpress

Get this FREE eBook & Beautify Your WordPress site.

Also get 300+ most essential FREE wordpress plugin lists.

Attracting potential visitors is hard enough for every blogger but grabbing their interest and retaining then is even more difficult for so many reasons. Get this Amazing FREE eBook to learn the tricks to Beautify Your WordPress Blog.

Please check your inbox. And also don\\\'t forget to Check Spam box.

Share This