From a1155af6a048f6e16c8403fcb682a72aae4bf1ab Mon Sep 17 00:00:00 2001 From: magdev Date: Wed, 4 Feb 2026 10:24:31 +0100 Subject: [PATCH] Fix AJAX handler timing: register directly instead of on woocommerce_loaded The woocommerce_loaded hook may have already fired by the time our plugin initializes. Register the AJAX handler directly since we've already verified WooCommerce is active. Co-Authored-By: Claude Opus 4.5 --- src/Integration/WooCommerce/Manager.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Integration/WooCommerce/Manager.php b/src/Integration/WooCommerce/Manager.php index 4490c98..2c2a1b9 100644 --- a/src/Integration/WooCommerce/Manager.php +++ b/src/Integration/WooCommerce/Manager.php @@ -130,8 +130,9 @@ final class Manager { // Declare HPOS compatibility. add_action( 'before_woocommerce_init', array( self::class, 'declare_hpos_compatibility' ) ); - // Always register admin AJAX handlers (for settings page). - add_action( 'woocommerce_loaded', array( ProductSync::class, 'init_admin_ajax' ) ); + // Always register admin AJAX handlers immediately (for settings page). + // Must be called directly, not via hook, since woocommerce_loaded may have already fired. + ProductSync::init_admin_ajax(); // Only initialize full components if integration is enabled. if ( ! self::is_enabled() ) {