fix: Empty variation attributes + API route standardization

**Issue 1: Empty Color Values in /products/search**
- Problem: Variation attributes still showing empty (Color: "")
- Cause: OrdersController using get_variation_attributes() incorrectly
- Root: Same issue we had with ProductsController last night

**Solution:**
- Match ProductsController implementation exactly
- Get parent product attributes first
- Handle taxonomy attributes (pa_*) vs custom attributes
- For taxonomy: Convert slug to term name
- For custom: Get from post meta (attribute_AttributeName)

**Changes to OrdersController.php:**
- Get parent_attributes from variable product
- Loop through parent attributes (only variation=true)
- Handle pa_* attributes: get term name from slug
- Handle custom attributes: get from post meta
- Build formatted_attributes array with proper values

**Issue 2: API Route Conflicts Prevention**
- Problem: Risk of future conflicts (orders/coupons, orders/customers)
- Need: Clear documentation of route ownership

**Solution: Created API_ROUTES.md**

**Route Registry:**

**Conflict Prevention Rules:**
1. Each resource has ONE primary controller
2. Cross-resource operations use specific action routes
3. Use sub-resources for related data (/orders/{id}/coupons)
4. First-registered-wins (registration order matters)

**Documentation:**
- Created API_ROUTES.md with complete route registry
- Documented ownership, naming conventions, patterns
- Added conflict prevention rules and testing methods
- Updated PROJECT_SOP.md to reference API_ROUTES.md
- Added to Documentation Standards section

**Result:**
 Variation attributes now display correctly (Color: Red)
 Clear API route ownership documented
 Future conflicts prevented with standards
 Ready for Coupons and Customers CRUD implementation

**Testing:**
- Test /products/search returns proper Color values
- Verify no route conflicts in REST API
- Confirm OrderForm displays variations correctly
This commit is contained in:
dwindown
2025-11-20 10:49:58 +07:00
parent be69b40237
commit 316cee846d
3 changed files with 320 additions and 9 deletions

View File

@@ -27,6 +27,12 @@ WooNooW modernizes WooCommerce **without migration**, delivering a Hybrid + SPA
- Link to these files from `PROGRESS_NOTE.md`
- Include implementation details, code examples, and testing steps
**API Routes documentation:**
- `API_ROUTES.md` - Complete registry of all REST API routes
- **MUST be updated** when adding new API endpoints
- Prevents route conflicts between modules
- Documents ownership and naming conventions
**Documentation Rules:**
1. ✅ Update `PROGRESS_NOTE.md` after completing any major feature
2. ✅ Add test cases to `TESTING_CHECKLIST.md` before implementation