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 3 days, 14 hours ago.

Assisted by: Waqas Bin Hasan.

Author Posts
November 28, 2024 at 4:07 am #16452227

desireeM

Background of the issue:
is_cart() and is_checkout() cannot be used on "init" hook, the earliest is "wp" - if it's called before that they will always return false
See hidden link
However you call them on "init" hook

Here's a partial stack trace highlighting the issue:

...
#7 /wp-content/plugins/woocommerce-multilingual/compatibility/WcSubscriptions/MulticurrencyHooks.php (107): is_cart()
#8 /wp-content/plugins/woocommerce-multilingual/compatibility/WcSubscriptions/MulticurrencyHooks.php (49): WCMLCompatibilityWcSubscriptionsMulticurrencyHooks->maybe_force_client_currency_for_subscription()
#9 /wp-includes/class-wp-hook.php (...): WCMLCompatibilityWcSubscriptionsMulticurrencyHooks->init()
...
#12 /wp-settings.php (...): do_action( $hook_name = 'init' )
...

Do you have any e2e tests internally? Bc whatever you try to do, never works, since is_cart/is_checkout will always return false on init hook

Btw same issue also "is_front_page()" WP (not WC) conditional, which, if called on "init" has not been initiated usually, since "parse_query" hasn't run on the main query yet

...
#5 /wp-content/plugins/wp-seo-multilingual/classes/Utils.php (52): is_front_page()
#6 /wp-content/plugins/wp-seo-multilingual/classes/Presentation/Hooks.php (33): WPMLWPSEOUtils::isFrontPageWithPosts()
#7 /wp-includes/class-wp-hook.php (...): WPMLWPSEOPresentationHooks->init()
...
#10 /wp-settings.php (...): do_action( $hook_name = 'init' )
...
#13 /wp-blog-header.php (13): require_once( '/wp-load.php' )
#14 /index.php (17): require( '/wp-blog-header.php' )

Symptoms:
The conditional tags is_cart(), is_checkout(), and is_front_page() return false when used on the 'init' hook.

Questions:
Please fix your code

December 2, 2024 at 10:45 am #16465468

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:53 pm #16466168

Waqas Bin Hasan
Supporter

Languages: English (English )

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

Thank you for your patience and cooperation.

May I request little more details on the said issue, like what problem exactly it is causing in your site?

Also I request some steps about how I can reproduce this issue in a clean environment? I'm trying to understand the side-effects of these early calls.

December 6, 2024 at 2:53 pm #16486525

desireeM

create a callback on "init" in which you call "is_checkout()"
Go to checkout page - you will see it returns false

December 9, 2024 at 4:48 am #16490897

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:03 am #16496225

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.

On the following pages, you can see these all return false:

- Front page: hidden link
- Cart: hidden link
- Checkout: 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:32 am #16516711

desireeM

Can you please ask somebody who has basic knowledge of PHP debugging and WP hooks bc your reply makes no sense - it's obviously expected that the test code will tigger even if no other plugins are active - it's literally to show you the example in a simple test case.

December 17, 2024 at 10:08 am #16520790

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:59 am #16525076

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 #16529862

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.