v1.2.0 - Fix product selection, cart pricing, admin tabs + CI/CD

Fix three critical bugs that persisted through v1.1.11-v1.1.14:

- Product selection always empty: meta_query checked _product_type in
  postmeta, but WooCommerce uses the product_type taxonomy. Replaced
  with correct tax_query using NOT IN operator.
- Cart price always 0.00: composable_price_calculated flag persisted
  in session, preventing recalculation on page loads. Removed flag;
  static variable already handles per-request dedup.
- Admin tabs both visible on load: JS now triggers WooCommerce native
  tab click instead of manually toggling panel visibility.

Add Gitea CI/CD release workflow triggered on v* tags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 12:01:20 +01:00
parent 29a68b0be4
commit 6507f4d8bb
68 changed files with 351 additions and 82 deletions

View File

@@ -255,8 +255,9 @@ unzip -l wc-composable-product-vX.X.X.zip
-~~Small rendering Bug in admin area. If you load the side, on first view it shows the first both tabs.~~ **FIXED in v1.1.8**
-~~In the frontend, regardless which selection mode you use, there appears no product selection in any way.~~ **FIXED in v1.1.8**
-~~The pricing field in the frontend should be rendered as localized price field include currency.~~ **FIXED in v1.1.8**
- Still no product selection in frontend. Current mode 'by Category', but 'by tag' also didn't work
- The tab rendering is still no correct. first both tabs are shown on initial page load. After clicking a tab, they behave as expected. Update: I Think there is a collision with the dynamicly changing the criteria with the related field and the tab switching function.
- ~~Still no product selection in frontend. Current mode 'by Category', but 'by tag' also didn't work~~ **FIXED in v1.2.0** - Root cause: meta_query checked `_product_type` in postmeta, but WooCommerce stores product types in the `product_type` taxonomy. The `!=` comparison with a non-existent meta key caused INNER JOIN returning zero results. Fixed by using correct `tax_query`.
- ~~The tab rendering is still no correct. first both tabs are shown on initial page load. After clicking a tab, they behave as expected.~~ **FIXED in v1.2.0** - JS now triggers WooCommerce's native tab click instead of manually toggling panel visibility.
-~~Cart price always 0.00 despite correct frontend price calculation~~ **FIXED in v1.2.0** - `composable_price_calculated` session flag prevented price recalculation on subsequent page loads.
## Session History
@@ -1883,6 +1884,64 @@ This session demonstrated the importance of changing debugging strategy after mu
---
### v1.2.0 - Critical Bug Fixes & CI/CD (2026-03-01)
#### Session 15: Root Cause Discovery and Automated Releases
**Major bug fix release** resolving three long-standing issues that persisted through v1.1.11-v1.1.14.
**Bugs fixed:**
1. **Product selection always empty** (the real root cause, finally found!)
- **Root cause**: `includes/Product_Type.php` line 117-124 had a `meta_query` checking `_product_type != 'composable'` in `wp_postmeta`. But WooCommerce stores product types in the `product_type` **taxonomy**, not in postmeta. The `!=` comparison on a non-existent meta key generates an `INNER JOIN` on `wp_postmeta` that matches zero rows — returning no products at all.
- **Fix**: Replaced `meta_query` with correct `tax_query` using `product_type` taxonomy with `NOT IN` operator.
- **Why v1.1.11-v1.1.14 failed**: All previous fix attempts addressed symptoms (variable products, stock filtering, debug logging) but never examined the actual WP_Query construction. The meta_query was the root cause all along.
2. **Cart price always 0.00**
- **Root cause**: `includes/Cart_Handler.php` stored a `composable_price_calculated` flag in the cart session. On the next page load (cart, checkout), this flag was restored from session and prevented price recalculation — but `set_price()` only modifies the in-memory product object and is lost between requests.
- **Fix**: Removed the per-item `composable_price_calculated` flag entirely. The existing `static $already_calculated` flag already handles the "don't run twice in the same request" concern.
3. **Admin tab rendering on initial page load**
- **Root cause**: JavaScript called `$('#composable_product_data').show()` which made the composable panel visible without hiding the General panel that WooCommerce shows by default.
- **Fix**: Trigger WooCommerce's native tab click (`$('ul.product_data_tabs li.composable_options a').trigger('click')`) so the tab system handles panel visibility correctly.
**New feature:**
4. **Gitea CI/CD release workflow** (`.gitea/workflows/release.yml`)
- Triggered on `v*` tags
- Installs PHP 8.3, Composer deps (production), compiles translations
- Verifies plugin version matches tag
- Builds release ZIP with proper WordPress directory structure
- Generates SHA-256 checksums, verifies package structure
- Creates Gitea release with ZIP and checksum attachments
- Uses `SRC_GITEA_TOKEN` secret for Gitea API
**Files modified:**
- includes/Product_Type.php: Replaced `meta_query` with `tax_query`, removed debug logging
- includes/Cart_Handler.php: Removed `composable_price_calculated` session flag
- assets/js/admin.js: Use native WooCommerce tab click instead of manual panel toggle
**Files created:**
- .gitea/workflows/release.yml: Gitea CI/CD release workflow
**Key lessons learned:**
1. **WooCommerce stores product types in taxonomy, not postmeta**: This is the single most important lesson from the entire v1.1.11-v1.1.14 debugging saga. `_product_type` does NOT exist in `wp_postmeta` — product types are terms in the `product_type` taxonomy.
2. **WP_Query `!=` on non-existent meta keys returns zero results**: When you use `'compare' => '!='` in a meta_query, WordPress generates an `INNER JOIN` that only matches posts having that meta key. Posts without the key are excluded entirely.
3. **Don't persist calculation flags in cart sessions**: `set_price()` only modifies in-memory objects. Any flag that prevents recalculation must NOT be stored in session data — use request-scoped variables (like `static`) instead.
4. **Use native WooCommerce UI mechanisms**: For tab/panel visibility, trigger WooCommerce's own click handlers rather than manually toggling visibility. WooCommerce's tab system handles hiding all other panels automatically.
5. **Read the actual query, not just the results**: v1.1.11-v1.1.14 all tried to fix what happened AFTER the query (stock filtering, variation expansion, debug logging), but the query itself was the problem.
**Status:** v1.2.0 released with all three bugs resolved and CI/CD automation added.
---
**For AI Assistants:**
When starting a new session on this project: