atal Error in Background/Cron Tasks: Call to undefined function wc_get_page_screen_id() in woocs_hpos.php
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page pleaseIf you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
Quote from parhelion on September 16, 2026, 00:45Hi team,
We are encountering a fatal error during automated cron executions. (specifically when background tasks like Jetpack Sync run
wc_get_order()).Fatal error: Uncaught Error: Call to undefined function wc_get_page_screen_id() in wp-content/plugins/woocommerce-currency-switcher/classes/woocs_hpos.php:55
Stack trace:
#0 wp-content/plugins/woocommerce-currency-switcher/index.php(582): WoocsHpos->getOrderScreenId()
#1 wp-content/plugins/woocommerce-currency-switcher/index.php(384): woocs_is_admin_order_edit_context()
#2 wp-includes/class-wp-hook.php(355): {closure}()
#3 wp-includes/plugin.php(206): WP_Hook->apply_filters()
#4 wp-includes/option.php(256): apply_filters()
...
#17 wp-includes/wc-order-functions.php(94): WC_Order_Factory::get_order()
#24 wp-includes/class-wp-hook.php(353): Automattic\Jetpack\Sync\Actions::do_cron_sync()
#27 wp-cron.php(191): do_action_ref_array()Cause
The function
wc_get_page_screen_id()is loaded exclusively inside the admin context (woocommerce/includes/admin/wc-admin-functions.php).When background workers, WP-CLI, or WP-Cron load orders via
wc_get_order(), option filters triggerwoocs_is_admin_order_edit_context(), which invokesWoocsHpos::getOrderScreenId(). Since the admin functions file is not loaded in non-admin/cron contexts, it results in an unhandledE_ERROR.Suggested Fix
In
classes/woocs_hpos.php, you can check if the function exists or directly use\Automattic\WooCommerce\Utilities\OrderUtil::get_order_admin_screen():public function getOrderScreenId(): string {
if ( ! class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) ) {
return 'shop_order';
}if ( \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled() ) {
if ( function_exists( 'wc_get_page_screen_id' ) ) {
return wc_get_page_screen_id( 'shop-order' );
}
return \Automattic\WooCommerce\Utilities\OrderUtil::get_order_admin_screen();
}return 'shop_order';
}Could you please patch this in the next release to prevent background cron processes from failing?
Thanks!
Hi team,
We are encountering a fatal error during automated cron executions. (specifically when background tasks like Jetpack Sync run wc_get_order()).
Fatal error: Uncaught Error: Call to undefined function wc_get_page_screen_id() in wp-content/plugins/woocommerce-currency-switcher/classes/woocs_hpos.php:55
Stack trace:
#0 wp-content/plugins/woocommerce-currency-switcher/index.php(582): WoocsHpos->getOrderScreenId()
#1 wp-content/plugins/woocommerce-currency-switcher/index.php(384): woocs_is_admin_order_edit_context()
#2 wp-includes/class-wp-hook.php(355): {closure}()
#3 wp-includes/plugin.php(206): WP_Hook->apply_filters()
#4 wp-includes/option.php(256): apply_filters()
...
#17 wp-includes/wc-order-functions.php(94): WC_Order_Factory::get_order()
#24 wp-includes/class-wp-hook.php(353): Automattic\Jetpack\Sync\Actions::do_cron_sync()
#27 wp-cron.php(191): do_action_ref_array()
Cause
The function wc_get_page_screen_id() is loaded exclusively inside the admin context (woocommerce/includes/admin/wc-admin-functions.php).
When background workers, WP-CLI, or WP-Cron load orders via wc_get_order(), option filters trigger woocs_is_admin_order_edit_context(), which invokes WoocsHpos::getOrderScreenId(). Since the admin functions file is not loaded in non-admin/cron contexts, it results in an unhandled E_ERROR.
Suggested Fix
In classes/woocs_hpos.php, you can check if the function exists or directly use \Automattic\WooCommerce\Utilities\OrderUtil::get_order_admin_screen():
public function getOrderScreenId(): string {
if ( ! class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) ) {
return 'shop_order';
}if ( \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled() ) {
if ( function_exists( 'wc_get_page_screen_id' ) ) {
return wc_get_page_screen_id( 'shop-order' );
}
return \Automattic\WooCommerce\Utilities\OrderUtil::get_order_admin_screen();
}return 'shop_order';
}
Could you please patch this in the next release to prevent background cron processes from failing?
Thanks!
Quote from Alex Dev on September 17, 2026, 19:53Hello
Thank you for the report, and thank you for the full stack trace. It confirmed the cause immediately.
We are not going to use OrderUtil::get_order_admin_screen() as the fallback. Internally it calls COTMigrationUtil::get_order_admin_screen(), which throws an exception when is_admin() is false, so in a real background context it would replace one fatal error with another. A plain guard is safer.
You can apply the fix right now. Open classes/woocs_hpos.php, make a backup first, and replace the getOrderScreenId method with this version:
public function getOrderScreenId(): string { if (!function_exists('wc_get_container') || !class_exists('Automattic\WooCommerce\Utilities\OrderUtil') || !function_exists('wc_get_page_screen_id') || !class_exists('WC_Admin_Menus')) { return ''; } // @phpstan-ignore-next-line $screen = wc_get_container()->get(HposController::class)->custom_orders_table_usage_is_enabled() ? wc_get_page_screen_id('shop-order') : 'shop_order'; return $screen; }Both places that call this method already handle an empty string correctly, so nothing else needs to be touched.
Please tell us whether the cron errors stop after this. We plan to release the update with this fix included, most likely this week, so the manual edit is only a stopgap until then.
Best regards
Alex
Hello
Thank you for the report, and thank you for the full stack trace. It confirmed the cause immediately.
We are not going to use OrderUtil::get_order_admin_screen() as the fallback. Internally it calls COTMigrationUtil::get_order_admin_screen(), which throws an exception when is_admin() is false, so in a real background context it would replace one fatal error with another. A plain guard is safer.
You can apply the fix right now. Open classes/woocs_hpos.php, make a backup first, and replace the getOrderScreenId method with this version:
public function getOrderScreenId(): string {
if (!function_exists('wc_get_container') || !class_exists('Automattic\WooCommerce\Utilities\OrderUtil') || !function_exists('wc_get_page_screen_id') || !class_exists('WC_Admin_Menus')) {
return '';
}
// @phpstan-ignore-next-line
$screen = wc_get_container()->get(HposController::class)->custom_orders_table_usage_is_enabled() ? wc_get_page_screen_id('shop-order') : 'shop_order';
return $screen;
}Both places that call this method already handle an empty string correctly, so nothing else needs to be touched.
Please tell us whether the cron errors stop after this. We plan to release the update with this fix included, most likely this week, so the manual edit is only a stopgap until then.
Best regards
Alex
Quote from Alex Dev on September 18, 2026, 17:18Hello
Update is just done (v.1.5.4), and fix is there
Hello
Update is just done (v.1.5.4), and fix is there
Quote from parhelion on September 22, 2026, 21:47Hello Alex, it is now fixed by update, thanks 🙌
Hello Alex, it is now fixed by update, thanks 🙌
Quote from Alex Dev on September 23, 2026, 11:58Hello Mustafa
You are Welcome :)
Hello Mustafa
You are Welcome :)