I was trying setup a paypal gateway but I was getting an error:
Gateway Disabled: PayPal does not support your store currency
By default, I have an AED Currency so I’m trying to convert it to USD when checking out to paypal but right now it is not working.
I have this in my theme’s functons.php
file:
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['AED'] = __( 'Emirati Dirham', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'AED': $currency_symbol = 'AED'; break;
}
return $currency_symbol;
}
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ), 20 );
add_filter( 'woocommerce_billing_fields', 'wc_billing_fields_state_filter', 10, 1 );
function wc_billing_fields_state_filter( $address_fields ) {
$address_fields['billing_state']['label'] = 'Emirate';
$address_fields['billing_state']['placeholder'] = 'Emirate';
return $address_fields;
}
EDIT: I’ve deactivated the plugin “All Currencies for WooCommerce” and the settings menu is now showing. But PayPal Gateway is still not allowed since AED is not a supported currency. How do I convert it to USD upon paying with PayPal?
The code above doesn’t seem to work
The code you have adds AED to the list of the currencies “supported” by the PayPal gateway, but it doesn’t perform any conversion to USD. To perform a conversion, you will need a couple of things:
Depending on the multi-currency solution in use, the exact approach could be slightly different. As the developer of the Currency Switcher for WooCommerce, I solved all of the above for my clients, using the plugins I developed and some custom code.
You can find the custom code that applies to our plugins in our knowledge base: Is it possible to use the Currency Switcher to allow Users to select a currency, but force payment in base currency, or an arbitrary currency?.
Whether you decide to use our plugins or not, the code should be a good starting point to implement a solution.