Selaa lähdekoodia

add HPOS support

Dalibor Votruba 8 kuukautta sitten
vanhempi
commit
202feaeca9

+ 16 - 3
studiou-wc-ord-print-statuses/CLAUDE.md

@@ -28,15 +28,24 @@ Modified the query (lines 55-65 in `includes/class-db-manager.php`) to:
 2. Look for meta_key = 'attribute_pa_format' which stores the variation's format attribute value
 3. Join with `wp_terms` using the slug field (matching against meta_value) instead of term_id
 
+**HPOS Compatibility Declaration**
+
+Added explicit HPOS (High-Performance Order Storage) compatibility declaration to prevent WooCommerce warnings.
+
+**Solution:**
+Added `before_woocommerce_init` hook in the main plugin file to declare compatibility with WooCommerce custom order tables using `FeaturesUtil::declare_compatibility()`.
+
 **Files Changed:**
 - `includes/class-db-manager.php` - Updated LEFT JOIN logic for product_variations_attr and product_variations_name tables
+- `studiou-wc-ord-print-statuses.php` - Added HPOS compatibility declaration
 
 **Impact:**
-The `prod_var_type` column in exported CSV files now correctly displays the Format attribute value (e.g., "A4", "A5") for each product variation.
+- The `prod_var_type` column in exported CSV files now correctly displays the Format attribute value (e.g., "A4", "A5") for each product variation
+- Plugin no longer shows HPOS incompatibility warnings in WooCommerce
 
 **Tested On:**
 - WordPress 6.8.3
-- WooCommerce 10.2.2
+- WooCommerce 10.2.2 (with HPOS enabled)
 
 ## Architecture
 
@@ -138,7 +147,11 @@ The plugin supports internationalization:
 
 ## Important Considerations
 
-1. **HPOS Compatibility**: The plugin uses `woocommerce_page_wc-orders` hooks, indicating support for WooCommerce High-Performance Order Storage (HPOS)
+1. **HPOS Compatibility**: The plugin is fully compatible with WooCommerce High-Performance Order Storage (HPOS)
+   - Uses `woocommerce_page_wc-orders` hooks for HPOS compatibility
+   - Uses `{$wpdb->prefix}wc_orders` table (HPOS custom table) in SQL queries
+   - Uses `wc_get_order()` which works with both HPOS and legacy systems
+   - Declares compatibility via `FeaturesUtil::declare_compatibility('custom_order_tables', ...)`
 
 2. **Status Slug Naming**: Custom statuses use `wc-` prefix internally but display without prefix (`wc-to-print` vs "Prepare to Printing")
 

+ 5 - 1
studiou-wc-ord-print-statuses/readme.md

@@ -12,6 +12,7 @@ QDR - Studiou WC Order Print Statuses is a WordPress plugin that extends WooComm
 - Custom columns in the orders list for quick view of print statuses
 - Import functionality for InPrint and Delivered protocols
 - Search orders by external reference order number
+- Full compatibility with WooCommerce High-Performance Order Storage (HPOS)
 
 ## Installation
 
@@ -76,9 +77,12 @@ For support, please contact the plugin author at https://www.quadarax.com
 
 ### Version 1.3.2 (2025-10-18)
 - **Fixed:** Empty `prod_var_type` column in CSV export when using "Prepare to Printing Export" bulk action
+- **Fixed:** HPOS (High-Performance Order Storage) compatibility warning in WooCommerce
 - **Changed:** Updated database query to correctly retrieve product variation format attribute from `wp_postmeta` table
+- **Changed:** Added explicit HPOS compatibility declaration to prevent WooCommerce warnings
 - **Impact:** CSV exports now properly display Format attribute values (e.g., A4, A5) for product variations
-- **Tested:** WordPress 6.8.3, WooCommerce 10.2.2
+- **Impact:** Plugin now fully compatible with WooCommerce HPOS (custom order tables)
+- **Tested:** WordPress 6.8.3, WooCommerce 10.2.2 (with HPOS enabled)
 
 ### Version 1.3.1
 - Previous stable version

+ 7 - 0
studiou-wc-ord-print-statuses/studiou-wc-ord-print-statuses.php

@@ -19,6 +19,13 @@
 
 defined('ABSPATH') || exit;
 
+// Declare HPOS (High-Performance Order Storage) compatibility
+add_action('before_woocommerce_init', function() {
+    if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
+        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
+    }
+});
+
 // load logging feature
 require_once plugin_dir_path(__FILE__) . 'includes/utils-log.php';