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:
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.
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.
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?
>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.