Last active
March 20, 2025 18:35
-
-
Save richardblondet/b8c6f2110ab2b5e6ca7658a05d82aeec to your computer and use it in GitHub Desktop.
Enable unsupported currency to Woocommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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; | |
} |
Thank you,
There is also another solution on https://8y35.com/woocommerce/how-to-fix-woocommerce-paypal-unsupported-currency-issue/
Would you recommend it?
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
Clean code, save me alot. Cheers and Thanks.