Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client needed to assign specific payment gateways and the 'cash on delivery' method to different currencies using WooCommerce Multilingual & Multicurrency. The built-in functionality was limited and did not support the client's payment gateways.

Solution:
We first directed the client to our documentation on setting up payment gateways for each currency: https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/#setting-up-payment-gateways-for-each-currency.

After further clarification and internal discussion, we acknowledged that there is no out-of-the-box solution for unsupported gateways. We suggested using the

woocommerce_payment_gateways

hook to add or remove gateways based on the selected currency. We provided an example code snippet to guide the client:

add_filter( 'woocommerce_payment_gateways', 'add_gw' );<br /><br />function add_gw( $methods ) {<br />    $currency = get_woocommerce_currency();<br />    if ($currency == "EUR") {<br />        $methods[] = 'Custom Gateway Class';<br />        return $methods;<br />    } else {<br />        return $methods;<br />    }<br />}

We also recommended that if the client requires further custom solutions, they should consider reaching out to our recommended third-party developers: https://wpml.org/contractors/.

Please note that this solution might be irrelevant due to being outdated or not applicable to your case. If so, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket with us.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 7 replies, has 2 voices.

Last updated by Michael 1 year, 1 month ago.

Assisted by: Bobby.

Author Posts
February 23, 2024 at 1:23 pm #15337909

Michael

WooCommerce Multilingual & Multicurrency has a setting called "Payment Gateways" which is designed to tie specific payment methods with specific currency. However, it seems that it has limited functionality since it only supports limited number of payment gateways.

So, I have two payment gateways and "cash on delivery" methods, also two currencies.

I would like to assign one gateway and COD to the first currency, and other gateway to another currency. So that the payment method would appear only when specific currency is selected.

How do I do that?

February 23, 2024 at 11:25 pm #15339651

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi,

Please review the following documentation:
https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/#setting-up-payment-gateways-for-each-currency

Let me know your results, please.

February 24, 2024 at 6:37 am #15339944

Michael

Hello Bobby,

Thank you for your reply.

As I mentioned in my initial request, this setting has limited functionality.

Take a look at my screenshots. I have two currencies, EUR and RUB.

1. There's no way to turn off unsupported payment gate "Pay online with Russian bank card" for EUR (I only need it to be shown for RUB).

2. There's no way to turn off "Cash on Delivery" for EUR (it doesn't even show up in the list).

3. And there's even no way to turn off "Manual bank transfer" for RUB (despite the fact the this payment method seems to be supported).

Снимок экрана 2024-02-24 в 09.34.17.png
Снимок экрана 2024-02-24 в 09.30.27.png
February 27, 2024 at 1:44 am #15346778

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for the screenshots!

If a currency is not supported by a specific payment gateway it will not give you the option to use the payment gateway.

Also, if a specific payment gateway is not supported then it will display but show not yet supported.

at the moment this feature is compatible with WooCommerce PayPal Payments, Stripe, and direct bank transfers.

February 27, 2024 at 6:17 pm #15350784

Michael

Thank you for your reply.

That is exactly what I've wrote in my initial request – this WCML option has limited functionality (btw it would be great to implement full functionality, see example screenshot of another currency plugin attached).

However, I still need to be able to limit specific payment gateways for each currency. Is there a way I can do that?

CNm2CfJRz7aPbzeE81WAupMBsX7CowCJKw.png
February 27, 2024 at 7:33 pm #15351056

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Yes, my misunderstanding thank you for the clarification!

There is no option out of the box to do this with WPML since these gateways are not supported, however, I have asked for a second opinion from our team so we can point you in the right direction.

Please note that custom solutions are outside the scope of our support but we will do our best to share any relevant information.

If a custom solution is required you can also reach out to our recommended third-party developers here:
https://wpml.org/contractors/

February 29, 2024 at 1:24 am #15356169

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

After discussing this with my team, our suggestion is to

Possibly achieve this by using the woocommerce_payment_gateways hook from WooCommerce you can remove or add the needed gateway...
Something like:

		add_filter( 'woocommerce_payment_gateways', 'add_gw' );

		function add_gw( $methods ) {
			$currency = get_woocommerce_currency();
			if ($currency == "EUR") {
				$methods[] = 'Custom Gateway Class';
				return $methods;
			} else {
				return $methods;
			}
		}

Or remove if the currency is not a specific currency... similar logic

Please note that this is shared only as a suggestion to help you move forward with your desired outcome, our team cannot provide custom work or maintain custom work if further assistance is required please reach out to our recommended third-party developers here:
https://wpml.org/contractors/

February 29, 2024 at 9:25 am #15356838

Michael

Thank you.

I've actually found the similar code on the other site yesterday.

So if someone will need it, please use it:

function foo_woocommerce_available_payment_gateways( $gateway_list ) {
$unsupported_currencies_by_gateway = array(
'payanyway' => array('EUR'), // hide payanyway for EUR
'cod' => array('EUR'), // hide cash on delivery for EUR
'bacs' => array('RUB') // hide bank for RUB
);
foreach ($unsupported_currencies_by_gateway as $gateway_key => $currencies) {
if ( isset( $gateway_list[ $gateway_key ] ) AND in_array( get_woocommerce_currency(), $currencies, true ) ) {
unset( $gateway_list[ $gateway_key ] );
}
}
return $gateway_list;
}
add_filter( 'woocommerce_available_payment_gateways', 'foo_woocommerce_available_payment_gateways', 1 );