Skip Navigation

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.

Elementor users - please update WPML to the latest version to maintain compatibility. More details here - https://wpml.org/changelog/2024/12/wpml-4-6-15-critical-update-for-elementor-sites/
Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 9 replies, has 0 voices.

Last updated by Waqas Bin Hasan 6 days, 14 hours ago.

Assisted by: Waqas Bin Hasan.

Author Posts
November 27, 2024 at 10:12 pm #16451819

desireeM

Background of the issue:
WCML loads woocommerce "get_available_payment_gateways" too early, before conditional tags are loaded, leading to incorrect list of available gateways.

woocommerce calls "is_add_payment_method_page" internally, which is a conditional tag hidden link that is only available on or after the "wp" action

WCML tries to load it on "wp_loaded" though.
You need to change your code to use a later hook (ideally "wp" or later)

Here's a partial stacktrace showing where it goes wrong:

...
/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php (325): is_add_payment_method_page()
/wp-content/plugins/woocommerce-multilingual/classes/multi-currency/payment-gateways/class-wcml-currencies-payment-gateways.php (212): WC_Payment_Gateways->get_available_payment_gateways()
/wp-content/plugins/woocommerce-multilingual/classes/multi-currency/payment-gateways/class-wcml-currencies-payment-gateways.php (97): WCML_Currencies_Payment_Gateways->get_available_payment_gateways()
/wp-includes/class-wp-hook.php (341): WCML_Currencies_Payment_Gateways->init_gateways()
/wp-includes/class-wp-hook.php (365): WP_Hook->apply_filters(...)
/wp-includes/plugin.php (521): WP_Hook->do_action(...)
/wp-settings.php (724): do_action( $hook_name = 'wp_loaded' )
/wp-config.php (378): require_once( '/wp-settings.php' )
/wp-load.php (51): require_once( '/wp-config.php' )
...

Symptoms:
Incorrect gateways loaded depending on the page one's on.

Questions:
Please fix your code

December 2, 2024 at 10:45 am #16465467

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

I'm checking with my team about the reported issue and 'll get back to you accordingly.

Thank you for your patience and cooperation.

Regards.

December 2, 2024 at 12:51 pm #16466163

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation.

May I request some steps about how I can reproduce this issue in a clean environment? I'm trying to reproduce in a sandbox site but probably missing some key points.

December 6, 2024 at 2:52 pm #16486521

desireeM

Open the wc payment-methods page in my-account and you will see that it returns false for "is_add_payment_method_page()" on "wp_loaded" hook.
If you try instead on "wp" hook you will get true.

December 9, 2024 at 4:46 am #16490896

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the updates. I am working on this and 'll get back to you as soon as I find something or have a solution.

December 10, 2024 at 8:04 am #16496229

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation.

I tried to reproduce the issue in a fresh sandbox site at hidden link (one-click login). But I noticed that the issue happens with only WooCommerce active in the site too.

This means there's no WPML plugin active and issue still can be reproduced, so I believe it is coming from WC, not WPML.

At hidden link, I've used "init" action. However if I use "wp" action, then these return correct (true) on the corresponding pages.

Again this is only happening with WC active in the site. You can login by using the above mentioned link. I've added the code in 2021 theme's functions.php file.

Can you please take some time and reproduce the issue where it really comes from WPML or WCML?

December 16, 2024 at 10:30 am #16516700

desireeM

>This means there's no WPML plugin active and issue still can be reproduced, so I believe it is coming from WC, not WPML.

Do you mean your custom "test" function triggers an error if only WC is active?
If yes, that is obviously expected.
The "test" function just showcases the bug WCML has.

I'm not even sure what to say, bc I'm really flabbergasted about your reply.

December 17, 2024 at 10:08 am #16520789

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the updates and apologies for your disappointment. I'll escalate the issue to our team and 'll update you accordingly.

December 18, 2024 at 9:58 am #16525075

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation, I've escalated the issue to our 2nd tier team and 'll update you as soon as their more to it.

December 19, 2024 at 11:43 am #16529861

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation, the matter has been escalated to our dev team.