Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save richardblondet/b8c6f2110ab2b5e6ca7658a05d82aeec to your computer and use it in GitHub Desktop.
Save richardblondet/b8c6f2110ab2b5e6ca7658a05d82aeec to your computer and use it in GitHub Desktop.
Enable unsupported currency to Woocommerce
/**
* @author: Svetto <https://devseon.com/en/wordpress-tutorials/woocommerce-add-a-paypal-unsupported-currency>
*/
add_filter( 'woocommerce_paypal_supported_currencies', 'add_a_paypal_valid_currency' );
function add_a_paypal_valid_currency( $currencies ) {
array_push ( $currencies , 'DOP' ); // DOP = Dominican Peso. Please change to your country code here.
return $currencies;
}
add_filter('woocommerce_paypal_args', 'convert_to_usd');
function convert_to_usd($paypal_args){
if ( $paypal_args['currency_code'] == 'DOP'){
$convert_rate = 47.5; // set the converting rate here
$paypal_args['currency_code'] = 'USD'; // change 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;
}
@mrkapable007
Copy link

Clean code, save me alot. Cheers and Thanks.

@Johnwpdev
Copy link

Thank you,
There is also another solution on https://8y35.com/woocommerce/how-to-fix-woocommerce-paypal-unsupported-currency-issue/
Would you recommend it?

@mrkapable007
Copy link

Hi, i looked into the solution provided, however i think it is not really fine grained. For example, when a store is in AED, KWD or SAR, the solution indicates that the store MUST be changed to USD or any supported currency.

I think the solution should be as indicated above, without the need to switch the store to a supported currency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment