From f62165488c2361e75dd5dc86a80de70c2781f841 Mon Sep 17 00:00:00 2001 From: Christopher Ross Date: Fri, 29 May 2026 18:50:01 +0000 Subject: [PATCH] Add WooCommerce HPOS and cart/checkout blocks compatibility declarations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Registers a `before_woocommerce_init` action that declares compatibility with the custom order tables (HPOS) and cart/checkout blocks features via `FeaturesUtil::declare_compatibility()`. The plugin already uses WC CRUD methods correctly (`get_user()`, `get_view_order_url()`), so the HPOS declaration is accurate. Declaring cart/checkout blocks compatibility removes the remaining "Not compatible" badge in WooCommerce → Status → Features. Closes #266 --- user-switching.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/user-switching.php b/user-switching.php index 5e72a70..c6259fa 100644 --- a/user-switching.php +++ b/user-switching.php @@ -94,6 +94,7 @@ public function init_hooks(): void { add_action( 'bbp_template_after_user_details_menu_items', [ $this, 'action_bbpress_button' ] ); // WooCommerce integration: + add_action( 'before_woocommerce_init', [ $this, 'action_before_woocommerce_init' ] ); add_action( 'woocommerce_login_form_start', [ $this, 'action_woocommerce_login_form_start' ], 10, 0 ); add_action( 'woocommerce_admin_order_data_after_order_details', [ $this, 'action_woocommerce_order_details' ], 1 ); add_filter( 'woocommerce_account_menu_items', [ $this, 'filter_woocommerce_account_menu_items' ], 999 ); @@ -1240,6 +1241,16 @@ public function action_enqueue_command_palette_script(): void { ); } + /** + * Declares compatibility with WooCommerce HPOS and cart/checkout blocks features. + */ + public function action_before_woocommerce_init(): void { + if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true ); + } + } + /** * Adds a 'Switch back to {user}' link to the WooCommerce login screen. */