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

@@ -2,7 +2,7 @@
## Milestone v0.1 — Naprawa funkcji w nowym layoucie strony produktu
Status: In progress (Phase 1 / 2 complete)
Status: **Ready to ship** — Phase 1 ✓, Phase 2 ✓ COMPLETE (02-01/02/03/04/05, 2026-04-24). Milestone UAT / IP gate removal pending.
Cel: przywrócić pełną funkcjonalność strony produktu w nowym wyglądzie (IP 89.69.31.86) bez naruszania starego.
@@ -12,24 +12,37 @@ Cel: przywrócić pełną funkcjonalność strony produktu w nowym wyglądzie (I
- Dotyczy tylko gałęzi `REMOTE_ADDR == '89.69.31.86'` w `product.tpl` oraz scope'owanego CSS/JS. Stary layout nietknięty.
- Summary: `.paul/phases/01-product-variants-fix/01-01-SUMMARY.md`
### Phase 02 — Product actions fixes (piece + add-to-cart + empty blocks) — **Planning**
### Phase 02 — Product actions fixes (piece + add-to-cart + customization + modal) — **✅ Complete (2026-04-24)**
Plan 02-01 (in planning): Konfigurator „piece" (crop + odbicie lustrzane) w nowym layoucie — port funkcjonalności ze starego layoutu z zachowaniem identycznego kontraktu DOM (hidden inputs `is_crop`, `crop_pos_x/y`, `crop_width/height`, `piece_bg_top/left`) dla serializacji do koszyka. Drag + resize przez inputy + mirror, re-init po AJAX refresh wariantu. Scope limit: zero nowych zależności, zero zmian w starym layoucie.
- Plan file: `.paul/phases/02-product-actions-fixes/02-01-PLAN.md`
Plan 02-01 (**✅ Complete**): Konfigurator „piece" (crop + odbicie lustrzane) w nowym layoucie — port funkcjonalności ze starego layoutu z identycznym kontraktem DOM. Drag + mirror + re-init po AJAX refresh. ✓
- Summary: `.paul/phases/02-product-actions-fixes/02-01-SUMMARY.md`
Plan 02-02 (**PARTIAL — closed 2026-04-23**): Add-to-cart submission działa (POST → cart saves item), ale customization nie zapisuje się i success modal nie pojawia. Core infrastructure: capture-phase native handler w custom.js + inline mirror w product.tpl (cache-buster), idempotency guard, blockcart refresh. 5 AC pass (technicznie), ale feature niekompletne z perspektywy UX.
- Plan file: `.paul/phases/02-product-actions-fixes/02-02-PLAN.md`
Plan 02-02 (**PARTIAL — closed 2026-04-23**): Add-to-cart submission działa (POST → cart saves item). Core infrastructure: capture-phase native handler w custom.js + inline mirror w product.tpl, idempotency guard, blockcart refresh. Customization + modal delegowane do 02-03.
- Summary: `.paul/phases/02-product-actions-fixes/02-02-SUMMARY.md`
- Uwaga: Plan 02-03 ujawnił że inline mirror z 02-02 nigdy nie renderował (Smarty `{extends}` block inheritance). AC-3 z 02-02 pass było przez custom.js alone; 02-03 przeniósł `{/block}` co definitywnie fix'uje mirror flow.
Plan 02-03 (**wymagany dla production** — kolejny do zaplanowania): Customization + success modal + cena per-sqm + systemowy cache-buster.
- Root cause: Plan 02-01 override `totalpriceinfospecific` na no-op wyłączył squaremeter flow → customization hook `hookActionObjectCartUpdateBefore` gate'owany `discretion=on` + wiele pól (`dim`, `qty`, `qty_alth`, `product_total_price_calc`, `extrafeevalue`, `wastevalue`, `calculated_total`, etc.) nie jest wypełnianych.
- Zakres:
1. Przywrócić squaremeter dimension flow w nowym layoucie (alternatywa dla `totalpriceinfospecific`) — UI dimension input'ów + live kalkulacja + synchronizacja hidden inputs.
2. Cena per-sqm kalkulacja (zależna od #1).
3. Success modal po add-to-cart przez POST do `/module/ps_shoppingcart/ajax?action=add-to-cart` → render modal (resp.modal HTML).
4. Systemowy cache-buster `?v=<mtime>` dla `<script src=custom.js>` — znaleźć miejsce rejestracji (theme.yml ma puste assets). Pozwoli wycofać inline mirror z product.tpl.
- Blocker dla publikacji nowego layoutu: TAK (produkcja wymaga modal + customization detail w koszyku).
Plan 02-03 (**✅ Complete 2026-04-24**): Customization save + success modal. 5/5 AC pass via live Playwright verification.
- Ground truth: Playwright capture 26-field OLD payload (verbose PL dim format, `qty_alt`/`qty_alth` osobno od `qty`, `product_total_price_calc` = int base × area).
- sq fields injection w POST do `/pl/koszyk`.
- Chain POST do `/module/ps_shoppingcart/ajax` → Bootstrap `#blockcart-modal` render z "Kontynuuj zakupy" + "Przejdź do kasy".
- Bug fix: `{/block}` move (inline script was dead code), `__p02p02InFlight` re-entrancy guard (double POST), basePrice fallback przez meta tag.
- Summary: `.paul/phases/02-product-actions-fixes/02-03-SUMMARY.md`
Kolejne plany w Phase 02 (po 02-03):
- Plan 02-04+ — Puste bloki `.product-protect`, `.product-installation`, `.product-order-sample` + potencjalnie brakujące elementy PS `updatedProduct` flow (`.js-product-images2-modal`, `.product-customization`, itd.)
- Opcjonalny add-on — resize handles bezpośrednio na `#piece` (bonus feature, user zgłosił w rozmowie).
Plan 02-04 (**✅ Complete 2026-04-24**): Live cena per-sqm labelka obok "Dodaj do koszyka" w nowym layoucie. 5/5 AC pass via Playwright.
- Scope pivot mid-task: label `.p02p04-total-price` obok buttona zamiast nadpisywania `.current-price` (user request). Górna "Od 239,00 zł / m²" zostaje statyczna.
- Reaktywność: piece dim changes (native input events), variant AJAX refresh (prestashop.on z poll-retry rejestracji).
- Separate `__p02p04Bound` guard + synchronous IIFE init + `setInterval` reconciliation (late-override protection).
- Summary: `.paul/phases/02-product-actions-fixes/02-04-SUMMARY.md`
Plan 02-05 (**✅ Complete 2026-04-24**): Struktura materiału w POST payload (production bug fix). 4/4 AC pass via Playwright network capture.
- Diagnoza: `<select id="group_5" name="group[5]">` (Tekstura materiału) POZA formą `#add-to-cart-or-refresh` w `.product-bar-box``$form.serialize()` nie łapie → PS saves default structure (id=9 Canvas) zamiast wybranej.
- Fix: enumeracja `[name^="group["]` spoza formy, encodeURIComponent + doklej do payload. Future-proof dla kolejnych attribute groups.
- Weryfikacja: Playwright network capture `group%5B5%5D=16` w payload, `id_product_attribute=4175` (new combination), `/pl/koszyk` pokazuje "Extra fine".
- Summary: `.paul/phases/02-product-actions-fixes/02-05-SUMMARY.md`
### Deferred (nice-to-have, nie blockers):
- **Plan 02-06** — Systemowy cache-buster `?v=<mtime>` dla `<script src=custom.js>` (inline mirror wycofać z Plan 02-02/02-03/02-04/02-05).
- **Plan 02-07** — Puste bloki `.product-protect`, `.product-installation`, `.product-order-sample`.
- Opcjonalny add-on — resize handles bezpośrednio na `#piece`.
**Milestone v0.1 ready na finalizację** — IP gate `REMOTE_ADDR == '89.69.31.86'` może zostać usunięty po UAT.