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.

Our next available supporter will start replying to tickets in about 4.57 hours from now. Thank you for your understanding.

This topic contains 2 replies, has 2 voices.

Last updated by Bruno 2 years, 6 months ago.

Assigned support staff: Arvish Mungur.

Author Posts
May 10, 2017 at 5:28 pm #1273107

Bruno

I am trying to:
Disable or hide a checkout method (or a so-called payment gateway) depending on the currency choosen by the customer.

Is there a nice way to do it ? Does this method is still relevant:
https://wpml.org/forums/topic/multi-currencypypal-option-not-available-for-my-secondary-currency/

Many thanks.

May 11, 2017 at 8:40 am #1273549

Arvish Mungur

Hello Bruno,

Thank you for contacting WPML support.

I will be happy to help with your issue.

To remove payment gateways based on currency, you can essentially use the same code as follows:

Modify as required and add the following to your theme’s functions.php

add_filter( 'woocommerce_available_payment_gateways', 'hide_gateways' );

function hide_gateways( $gateways ) {
global $woocommerce_wpml;
 
$get_current_currency_wcml = new WCML_Multi_Currency();
$get_current_currency = $get_current_currency_wcml->get_client_currency();
 
if( $get_current_currency == 'ABC' ){
//disable gateway paypal if currency is ABC
unset( $gateways['paypal'] );

} elseif( $get_current_currency == 'XYZ' ){

//disable gateway blabla if currency is XYZ
unset( $gateways['blabla'] );

}
else{
//otherwise disable gateway humdidum
unset( $gateways['humdidum'] );

}
return $gateways;
}

Please let me know if this works.

Kind regards

May 11, 2017 at 10:02 am #1273665

Bruno

Hi Arvish,
I knew that would be very easy to help me 😉
Thank you very much, that works perfectly.
Best regards