[Resolved] Assign Payment Method to a Specific Currency
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.
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:
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.
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.
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?
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/
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/
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 );
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.