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 thread is resolved. Here is a description of the problem and solution.

Problem: PyPal option not available for my secondary currency

Solution:
Recommended following code and advice. It worked.

add_filter( 'woocommerce_available_payment_gateways', 'hide_paypal' );
function hide_paypal( $gateways ) {
global $woocommerce_wpml;
 
$wcml_multi_currency = $woocommerce_wpml->get_multi_currency();
$get_current_currency = $wcml_multi_currency->get_client_currency();
 
if( $get_current_currency == 'ABC' )
unset( $gateways['paypal'] );
 
return $gateways;
}

*Initial issue is not related to WooCommerce Multilingual, it’s more about Woocommerce. If PayPal doesn’t have a currency then Woocommerce hides PayPal option from the checkout page. The WooCommerce Multilingual passes only the currency and amount to PayPal and nothing more*

Relevant Documentation:

This topic contains 12 replies, has 4 voices.

Last updated by tudorC-3 3 years, 1 month ago.

Assigned support staff: Bigul.

Author Posts
August 21, 2016 at 11:25 am #1012397

tudorC-3

Hi guys,

I am trying to: My primary currency (set in WooCommerce) is the Romanian Leu. I have activated a secondary currency in WPML WooCommerce Multi-Currency, the Euro, however I can not activate the PayPal option for it (probably because my primary currency, the Leu, is not supported by PayPal) and I need it because I want all my electronic payments in Euros to go through PayPal.

URL of (my) website where problem appears: hidden link

I expected to see: a posibility to activate PayPal for Euro while keeping it disabled for the Leu

Instead, I got: no PayPal gateway

Steps to duplicate the issue: this support ticket refferes to the same problem (https://wpml.org/forums/topic/woocommerce-multilingual-multi-currency-show-paypal-for-one-currency/) however I'm clueless as to where I should add the code in my WP instalation (in which files in which folders)

Can you please help?

Best regards,

Tudor

August 22, 2016 at 4:08 pm #1014384

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hello, Tudor.

Thank you for contacting the WPML support forum.

Thank you for providing here the link to the similar issue.

Yes, this code should go into your theme's functions.php file.
You will find this file in /wp-content/themes/your-theme-name/ folder
Place it at the end of the file and save.

I hope that this solution will work for you.

Thanks,
Itamar.

August 23, 2016 at 5:26 pm #1017633

tudorC-3

Hi Itamar,

The first step worked 🙂 I've got a little bit of a bump when i've added:

add_filter( 'woocommerce_available_payment_gateways', 'hide_paypal' );
function hide_paypal( $gateways ) {
    global $woocommerce_wpml;
 
    $get_current_currency = $woocommerce_wpml->multi_currency_support->get_client_currency();
 
    if( $get_current_currency == 'RON' )
        unset( $gateways['paypal'] );
 
    return $gateways;
}

I got the following notice and error:

Notice: Undefined property: woocommerce_wpml::$multi_currency_support in /*/chemistry/wp-content/themes/shopkeeper/functions.php on line 852

Fatal error: Call to a member function get_client_currency() on a non-object in /*/chemistry/wp-content/themes/shopkeeper/functions.php on line 852

Can you please help?

Best regards,

Tudor

August 24, 2016 at 3:58 pm #1020028

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, Tudor.

I've talked with Bruno, my colleague who had suggested this workaround in the ticket that you have referred to in your first reply.
Since it is an old issue, it seems that something had already changed within the code, and that is the reason that you get the error message.
In any case, I would like you to check the following plugin.
https://wpml.org/download/woocommerce-gateways-country-limiter/
It is a WooCommerce add-on that our developers have developed, and it looks like it fits your need with the issue that you are having with the Romanian Leu.
You can read more about the 'WooCommerce Gateways Country Limiter' here.
https://wpml.org/documentation/related-projects/woocommerce-gateways-country-limiter/

Please let me know if it helps you.

Thanks,
Itamar.

August 25, 2016 at 12:17 pm #1021534

tudorC-3

Hi Itamar,

first of all thank you for the research to both you and Bruno. I had a look at the WCGCL plugin and to my surprise, although I have it installed and activated, it does not add anything to my gateways pages under the Checkout tab in the Settings page of WooCommerce which was a bit strange...

Nonetheless, I didn't needed to limit the gateway by country but by currency...I don't want PayPal to be available for RON...otherwise, anyone willing to pay in Euros, no matter the location, is more than welcomed to do so for my business 🙂

Is there anything else you suggest I should try?

Best regards,

Tudor

August 26, 2016 at 8:44 am #1023589

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi there,

Itamar is off today, so I will take care of this queue. Hope that is Ok.

Are you trying to add support for paypal or trying to remove paypal option on certain languages as the code you are using here: https://wpml.org/forums/topic/multi-currencypypal-option-not-available-for-my-secondary-currency/#post-1017633 seems to be used to hide paypal option on certain langauges.

If you want to add support for paypal you can use the following code.https://wpml.org/forums/topic/woocommerce-multilingual-multi-currency-show-paypal-for-one-currency/#post-551888

I am confused what you are trying to achieve as well as which code are you using, so could you please explain a bit more.

I look forward to your reply.

Thanks

August 26, 2016 at 9:04 am #1023655

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi there,

Changing the default currency to Euro and making a configuration for default currency in Multi-currency can also help you, so could you please try this and let me know if that helps.

Thanks

August 31, 2016 at 9:47 am #1043401

tudorC-3

Hello,

I will re-explain:

- I want to have Romanian Leu as my default currency in WooCommerce and to define Euro as my secondary currency in WPML WooCommerce Multi Currency plugin
- I want to enable the PayPal option for Euro and to disable it for Romanian Leu (as the Romanian Leu is not an accepted Pay Pal currency yet)

I have manged to activate PayPal gateway for both currencies, now all I have to do is to disable it for RON (Romanian Leu). So, the filtering of the Pay Pal Gateway needs to be done by currency, not by language 🙂

Hope this sheds some more light.

Best regards,

Tudor

August 31, 2016 at 10:42 am #1046060

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi there,

It seems like you will need further programming work, which is beyond the scope of our support.

At this point I would suggest you consider contacting one of our certified partners from this link: http://wpml.org/documentation/support/wpml-contractors/

You will get the custom assistance you need to get on with your project.

Before doing so please have a look also here: http://wpml.org/documentation/support/wpml-contractors/guidelines-for-people-looking-for-consulting-help/

Thanks

August 31, 2016 at 2:46 pm #1046938

tudorC-3

Hi Shekhar,

No offense, as a paying customer I'm totally unhappy with your support in the replies you posted to the thread...can I please get Itamar back on my case? If not, maybe Bruno.

In https://wpml.org/forums/topic/woocommerce-multilingual-multi-currency-show-paypal-for-one-currency/ I saw Bruno giving a hand to the koteS, he mentioned nothing about extra coding being required...

Best regards,

Tudor

September 1, 2016 at 1:00 pm #1053424

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hello, Tudor.

I'm will continue to handle this ticket.

I'm currently trying to find out with my superiors if a fix to the code that Bruno has given in the past is possible.

I'll get back to you here when I'll have an answer.

Thank you for your patience.
Itamar.

September 2, 2016 at 11:09 am #1056020

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi Tudor,

I am Bigul from WPML support team. Itamar is off today. So I am take caring this ticket. Hope it will be okay for you.

Please try the following code and let me know your feedback.

add_filter( 'woocommerce_available_payment_gateways', 'hide_paypal' );
function hide_paypal( $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' )
unset( $gateways['paypal'] );

return $gateways;
}

For your information, we got the following feedback from our developers.

*Initial issue is not related to WooCommerce Multilingual, it’s more about Woocommerce. If PayPal doesn’t have a currency then Woocommerce hides PayPal option from the checkout page. The WooCommerce Multilingual passes only the currency and amount to PayPal and nothing more*

--
With Regards

Bigul

September 2, 2016 at 1:59 pm #1056523

tudorC-3

Guys, you are awesome, hugs & kisses! It works like a charm 🙂

Have a great weekend!

Tudor