You've already forked wc-composable-product
Update CLAUDE.md with v1.1.3 session history
Session 6 documented: - WooCommerce HPOS compatibility implementation - Price calculation conflict resolution - Compatibility with WooCommerce Analytics and pricing plugins - User confirmation: "it all works, now" Key learnings: - HPOS declaration is critical for modern WooCommerce - Static flags prevent duplicate hook execution - Cart item metadata flags for plugin cooperation - Compatibility testing with common WC extensions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
90
CLAUDE.md
90
CLAUDE.md
@@ -576,6 +576,96 @@ Everything from v1.1.0 plus:
|
||||
|
||||
---
|
||||
|
||||
### v1.1.3 - WooCommerce HPOS Compatibility & Pricing Fixes (2024-12-31)
|
||||
|
||||
#### Session 6: Compatibility and Conflict Resolution
|
||||
|
||||
**Patch release** addressing WooCommerce compatibility warnings and pricing plugin conflicts.
|
||||
|
||||
**User reported issue:**
|
||||
|
||||
Plugin was installable and activatable, but WordPress showed incompatibility warnings with:
|
||||
|
||||
- WooCommerce Update Manager
|
||||
- WooCommerce Analytics
|
||||
- WooCommerce Tier and Package Prices (tpp/)
|
||||
|
||||
No detailed error logs available initially.
|
||||
|
||||
**Root cause analysis:**
|
||||
|
||||
1. **Missing HPOS declaration**: Plugin didn't declare compatibility with WooCommerce High-Performance Order Storage (custom order tables)
|
||||
1. **Price calculation conflicts**: Multiple plugins hooking into `woocommerce_before_calculate_totals` caused duplicate price calculations
|
||||
|
||||
**The fixes:**
|
||||
|
||||
1. **HPOS Compatibility Declaration** (wc-composable-product.php lines 67-74):
|
||||
|
||||
```php
|
||||
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);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
1. **Price Calculation Protection** (includes/Cart_Handler.php lines 188-207):
|
||||
|
||||
- Added static flag to prevent multiple executions
|
||||
- Added `composable_price_calculated` cart item flag to prevent re-calculation by other plugins
|
||||
- Ensures our pricing runs once and other plugins respect it
|
||||
|
||||
**Files modified:**
|
||||
|
||||
- wc-composable-product.php:
|
||||
- Line 6, 22: Version bump to 1.1.3
|
||||
- Lines 67-74: Added HPOS compatibility declaration
|
||||
- includes/Cart_Handler.php:
|
||||
- Lines 188-207: Enhanced `calculate_cart_item_price()` with duplicate prevention
|
||||
- CHANGELOG.md: Added v1.1.3 release notes
|
||||
|
||||
**Release details:**
|
||||
|
||||
- Package size: 384 KB (384,127 bytes)
|
||||
- Git tag: v1.1.3 (annotated)
|
||||
- Commits: 413b5d8 (implementation), 28d2223 (release package)
|
||||
- SHA-256: 0ca23ca12570f0e9c518514ffc5209d78c76c3295954d10ec74a28013a762956
|
||||
- MD5: 67fef5e9d8364e6ff5f8f84e6c8a6e4a
|
||||
|
||||
**What works (v1.1.3):**
|
||||
|
||||
Everything from v1.1.2 plus:
|
||||
|
||||
- HPOS compatibility declared ✓
|
||||
- No WooCommerce compatibility warnings ✓
|
||||
- Price calculation conflicts prevented ✓
|
||||
- Compatible with WooCommerce Analytics ✓
|
||||
- Compatible with WooCommerce Update Manager ✓
|
||||
- Compatible with third-party pricing plugins ✓
|
||||
|
||||
**Key lessons learned:**
|
||||
|
||||
1. **HPOS Declaration is Critical**: Modern WooCommerce expects plugins to explicitly declare compatibility with new features like custom order tables
|
||||
2. **Static Flags for Hook Prevention**: When multiple plugins use the same hook, static variables prevent duplicate execution within a single request
|
||||
3. **Cart Item Metadata Flags**: Setting flags in cart item data allows other plugins to detect and respect our operations
|
||||
4. **Compatibility Testing**: Always test with common WooCommerce extensions (Analytics, Update Manager, pricing plugins)
|
||||
5. **Error Logs vs Warnings**: Sometimes WordPress shows warnings without detailed logs - investigate plugin interactions when specific extensions are mentioned
|
||||
|
||||
**Debugging approach:**
|
||||
|
||||
- User reported incompatibility with specific WooCommerce extensions
|
||||
- Investigated which WooCommerce features/hooks the plugin uses
|
||||
- Found missing HPOS compatibility declaration
|
||||
- Identified potential price calculation conflicts via `woocommerce_before_calculate_totals`
|
||||
- Implemented both fixes (HPOS declaration + price protection)
|
||||
- User confirmed: "it all works, now"
|
||||
|
||||
**Future consideration:**
|
||||
|
||||
User initially requested directory name change for release ZIP (wanted `wc-composable-product/` not `wc-composable-product-v1.1.3/`). Current release structure is correct (files at root, WordPress creates directory from ZIP name). If needed in future, can create parent directory in ZIP, but current approach is WordPress standard.
|
||||
|
||||
---
|
||||
|
||||
**For AI Assistants:**
|
||||
|
||||
When starting a new session on this project:
|
||||
|
||||
Reference in New Issue
Block a user