feat(02-product-actions-fixes): Phase 02 complete — customization, price label, structure fix

Plan 02-03: Customization save + success modal (5/5 AC)
- 26-field squaremeter POST payload (verbose PL dim, qty_alt/qty_alth)
- Chain POST /module/ps_shoppingcart/ajax -> Bootstrap #blockcart-modal
- Critical fix: moved {/block} so inline script actually renders
- __p02p02InFlight re-entrancy guard

Plan 02-04: Live cena per-sqm label obok "Dodaj do koszyka" (5/5 AC)
- .p02p04-total-price label, gorna .current-price static
- Separate __p02p04Bound + setInterval reconciliation
- Poll-retry prestashop.on registration

Plan 02-05: Struktura materialu w POST payload (4/4 AC)
- Enumerate [name^="group["] spoza formy, doklej do payload
- Fix: group_5 select w .product-bar-box nie trafial do koszyka

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-24 00:55:05 +02:00
parent 7ac795ba3f
commit ac03f807c1
13 changed files with 1583 additions and 64 deletions

View File

@@ -0,0 +1,125 @@
---
phase: 02-product-actions-fixes
plan: 05
subsystem: ui
tags: [prestashop, jquery, smarty, ps-attribute-groups, post-payload, new-layout]
requires:
- phase: 02-product-actions-fixes
provides: [add-to-cart handler + POST payload builder (02-02/02-03)]
provides:
- enumeracja external PS attribute group inputs w POST payload (dla atrybutów poza `#add-to-cart-or-refresh`)
- future-proof pattern dla przyszlych attribute groups (nie hardcode group[5])
affects: [przyszle PS attribute groups — plan zlapie je automatycznie]
tech-stack:
added: []
patterns:
- "Enumerate [name^='group['] poza formą → dołącz do payload (PS core delegated handlers tego nie robią per-se; my musimy bo nasz custom submit pomija non-form elementy)"
key-files:
created: []
modified:
- themes/ayon/assets/js/custom.js # +~13 lines payload builder
- themes/ayon/templates/catalog/product.tpl # +~13 lines inline mirror
key-decisions:
- "Enumerate wszystkie [name^='group['] spoza formy zamiast hardcode group[5] — future-proof"
- "Defensive `closest('#add-to-cart-or-refresh').length` check — unika duplicate gdyby kiedys przesuniete do formy"
- "Filter radio/checkbox przez :checked — unika duplicates z same-name grupy"
patterns-established:
- "Pattern: PS attribute groups moga byc w dowolnym miejscu template (poza formą) — custom submit MUSI je enumerować i doklejać manualnie"
duration: ~20min
started: 2026-04-24T22:40:00Z
completed: 2026-04-24T22:50:00Z
---
# Phase 02 Plan 02-05: Struktura materiału w POST payload — summary
**Enumeracja `[name^="group["]` inputs POZA formą `#add-to-cart-or-refresh` dołączana do POST payload — wybrana struktura materiału (`<select id="group_5">` w `.product-bar-box`) trafia do koszyka z prawidłowym `id_product_attribute`.**
## Performance
| Metric | Value |
|--------|-------|
| Duration | ~20 min |
| Started | 2026-04-24T22:40Z |
| Completed | 2026-04-24T22:50Z |
| Tasks | 3/3 completed |
| Files modified | 2 |
## Acceptance Criteria Results
| Criterion | Status | Notes |
|-----------|--------|-------|
| AC-1: `group[5]` w POST payload | **PASS** | Playwright network capture: `group%5B5%5D=16` obecne. `id_product_attribute=4175` w chain POST (nowe combination, nie domyślne 4171). |
| AC-2: Cart pokazuje wybraną strukturę | **PASS** | `/pl/koszyk` page tekst zawiera "Extra fine" (name struktury id=16). |
| AC-3: Defaults case | **PASS** | Reload fresh: payload zawiera `group%5B4%5D=5` (kolor default) + `group%5B5%5D=9` (struktura default Canvas) oba obecne. |
| AC-4: Zero regression OLD layout | **PASS** (code-path) | Handler guard `.product-variants-data--new` linia 1031 — early return w OLD, `externalGroups` code nigdy nie uruchamiany. Inline mirror tylko w `{if REMOTE_ADDR==...}` — nie renderuje dla OLD. PS core flow niezmieniony. |
## Accomplishments
- **Wybrana struktura materiału zapisuje się w koszyku** — production-blocking bug fixed. Klient kupuje co wybrał (nie domyślny Canvas).
- **Future-proof** — enumeracja wszystkich `[name^="group["]` spoza formy złapie dowolny nowy PS attribute group bez kolejnej zmiany kodu.
- **Zero scope creep** — plan wykonany 1:1 bez deviations. Czysta interwencja punktowa.
## Files Created/Modified
| File | Change | Purpose |
|------|--------|---------|
| `themes/ayon/assets/js/custom.js` | Modified (+13 lines) | Payload builder: enumeruj `[name^="group["]` outside form, skip radio/checkbox nie-checked, skip empty, encodeURIComponent + prepend do sqFields |
| `themes/ayon/templates/catalog/product.tpl` | Modified (+13 lines) | Identyczny blok w inline mirror IIFE (jQuery zamiast $) |
## Decisions Made
| Decision | Rationale | Impact |
|----------|-----------|--------|
| Enumerate wszystkie `[name^="group["]` spoza formy | Future-proof — nie hardcode `group[5]`; gdy sklep doda więcej PS attribute groups (np. rozmiar rolki, dzień dostawy), pattern automatycznie je złapie | Zero maintenance kosztu przy kolejnych atrybutach |
| Defensive `closest('#add-to-cart-or-refresh').length` check | Jesli kiedys template refactor przesunie group select DO formy, nasz kod nie będzie podwajać wartości w payload | Robustne wobec future template changes |
| Filter radio/checkbox przez `:checked` | jQuery `each` na `[name^="group["]` zwróci WSZYSTKIE radio buttons w danej grupie (np. 3 dla 3 kolorów). Bez :checked każdy by się dopisał — invalid payload | Poprawna semantika PS attribute group values |
## Deviations from Plan
### Summary
| Type | Count | Impact |
|------|-------|--------|
| Auto-fixed | 0 | — |
| Scope additions | 0 | — |
| Deferred | 1 | AC-4 live IP-flip test (code-path analysis sufficient) |
**Total impact:** None — plan wykonany dokładnie jak napisany. Pierwszy plan w Phase 02 bez mid-task deviations.
### Auto-fixed Issues
None.
### Deferred Items
- **AC-4 live IP-flip test** — zamiast kosztownego IP-flip deployu zastosowano code-path analysis (guard `.product-variants-data--new` na początku handlera). Argumenty korrektności silne, akceptowalne dla tego scope. Plan 02-04 miał identyczny wybor.
## Issues Encountered
| Issue | Resolution |
|-------|------------|
| Brak | — |
## Next Phase Readiness
**Ready:**
- **Milestone v0.1 COMPLETE** — Phase 02 full close. 5 plans shipped + verified. UX core flow działa: wariant kolorystyczny AJAX, piece config, add-to-cart submit, customization save, success modal, live price label, **wybór struktury do koszyka**.
- Phase transition + git commit pattern: bundled commit dla 02-03 + 02-04 + 02-05 (wszystkie uncommitted).
**Concerns:**
- Inline mirror wciąż obecny — Plan 02-06 (deferred cache-buster) pozwoli usunąć inline duplication z Plan 02-02/03/04/05.
- SPECIAL-FLOWS.md nadal nie skonfigurowane — Playwright MCP okazuje się krytyczny dla każdego phase plan ("structure-first diagnosis"). Rekomendacja z Plan 02-02 stoi.
**Blockers:**
- None.
---
*Phase: 02-product-actions-fixes, Plan: 05*
*Completed: 2026-04-24*