Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ef6dc9092 | ||
|
|
b03816e8ec | ||
|
|
591f2787ca | ||
|
|
e7b058c275 | ||
|
|
cbda17a91e | ||
|
|
60c346718e | ||
|
|
b1a6763f0d | ||
|
|
d3b4cbec5d | ||
|
|
99c7a3e5d8 | ||
|
|
ae016e362b | ||
|
|
10f9dfd85f | ||
|
|
131c26799f | ||
|
|
836b1c2596 | ||
|
|
8815d7842f | ||
|
|
72864d18ba | ||
|
|
4cda46d4bc | ||
|
|
ef58098e90 |
4
.claude/memory/MEMORY.md
Normal file
4
.claude/memory/MEMORY.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Memory Index
|
||||||
|
|
||||||
|
- [feedback_git_push_retry.md](feedback_git_push_retry.md) — Git push often fails on first attempt, always retry
|
||||||
|
- [feedback_updateignore_sonarqube.md](feedback_updateignore_sonarqube.md) — Never include .scannerwork/ and sonar-project.properties in update ZIPs
|
||||||
10
.claude/memory/feedback_git_push_retry.md
Normal file
10
.claude/memory/feedback_git_push_retry.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
name: git push retry
|
||||||
|
description: Git push to project-pro.pl often fails on first attempt - always retry before reporting failure
|
||||||
|
type: feedback
|
||||||
|
---
|
||||||
|
|
||||||
|
Git push do origin (git.project-pro.pl) czasem nie wchodzi za pierwszym razem. Zawsze ponawiaj push przed zgłoszeniem problemu użytkownikowi.
|
||||||
|
|
||||||
|
**Why:** Serwer git czasem odrzuca pierwsze połączenie (problem z autentykacją/połączeniem).
|
||||||
|
**How to apply:** Przy `git push` — jeśli pierwszy attempt fail, od razu ponów. Dopiero po 2-3 nieudanych próbach zgłoś problem.
|
||||||
10
.claude/memory/feedback_updateignore_sonarqube.md
Normal file
10
.claude/memory/feedback_updateignore_sonarqube.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
name: updateignore sonarqube
|
||||||
|
description: Never include .scannerwork/ and sonar-project.properties in update ZIP packages
|
||||||
|
type: feedback
|
||||||
|
---
|
||||||
|
|
||||||
|
Do paczki ZIP z aktualizacją nie dodawać katalogu `.scannerwork/` ani pliku `sonar-project.properties`.
|
||||||
|
|
||||||
|
**Why:** Są to pliki SonarQube — narzędzie deweloperskie, nie należą na serwer klienta.
|
||||||
|
**How to apply:** Upewnij się, że `.updateignore` zawiera te wpisy. Jeśli po buildzie w logu widać te pliki — naprawić `.updateignore` przed commitowaniem paczki.
|
||||||
14
.claude/memory/reference_sonarqube.md
Normal file
14
.claude/memory/reference_sonarqube.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
name: SonarQube scanner location
|
||||||
|
description: Path to sonar-scanner CLI installed locally with bundled JRE
|
||||||
|
type: reference
|
||||||
|
---
|
||||||
|
|
||||||
|
SonarQube scanner zainstalowany w `C:\tools\sonar-scanner-6.2.1.4610-windows-x64\bin\sonar-scanner.bat`
|
||||||
|
|
||||||
|
Dodany do PATH usera — po restarcie terminala dostępny jako `sonar-scanner`.
|
||||||
|
|
||||||
|
W bieżącej sesji bash używaj pełnej ścieżki: `"C:/tools/sonar-scanner-6.2.1.4610-windows-x64/bin/sonar-scanner.bat"`
|
||||||
|
|
||||||
|
Konfiguracja projektu: `sonar-project.properties` w katalogu głównym shopPRO.
|
||||||
|
Dashboard: https://sonar.project-pro.pl/dashboard?id=shopPRO
|
||||||
@@ -83,7 +83,7 @@ Właściciel sklepu internetowego ma pełną kontrolę nad sprzedażą online
|
|||||||
|
|
||||||
| Metric | Target | Current | Status |
|
| Metric | Target | Current | Status |
|
||||||
|--------|--------|---------|--------|
|
|--------|--------|---------|--------|
|
||||||
| Testy | >800 | 810 | On track |
|
| Testy | >800 | 821 | On track |
|
||||||
| Pokrycie architektury DDD | 100% | 100% | Achieved |
|
| Pokrycie architektury DDD | 100% | 100% | Achieved |
|
||||||
|
|
||||||
## Tech Stack
|
## Tech Stack
|
||||||
|
|||||||
@@ -35,6 +35,17 @@ Status: Planning
|
|||||||
|-------|------|-------|--------|-----------|
|
|-------|------|-------|--------|-----------|
|
||||||
| 7 | Coupon Fatal Error — order placement crash | 1 | Done | 2026-03-15 |
|
| 7 | Coupon Fatal Error — order placement crash | 1 | Done | 2026-03-15 |
|
||||||
| 8 | Apilo orders not sending — diagnoza i naprawa | 1 | Done | 2026-03-16 |
|
| 8 | Apilo orders not sending — diagnoza i naprawa | 1 | Done | 2026-03-16 |
|
||||||
|
| 9 | Apilo email notification + infinite retry | 1 | Done | 2026-03-19 |
|
||||||
|
|
||||||
|
## Feature
|
||||||
|
|
||||||
|
| Phase | Name | Plans | Status | Completed |
|
||||||
|
|-------|------|-------|--------|-----------|
|
||||||
|
| 10 | Edycja personalizacji produktu w koszyku | 1 | Done | 2026-03-19 |
|
||||||
|
| 11 | DataLayer GA4 analytics fix | 1 | Done | 2026-03-25 |
|
||||||
|
| 12 | summaryView redirect fix — double order block | 1 | Done | 2026-03-25 |
|
||||||
|
| 13 | Basket logging + TTL token fix | 1 | Done | 2026-03-25 |
|
||||||
|
| 14 | Custom fields delete bug — usunięcie wszystkich pól | 1 | Done | 2026-04-16 |
|
||||||
|
|
||||||
## Phase Details
|
## Phase Details
|
||||||
|
|
||||||
@@ -66,4 +77,31 @@ Status: Planning
|
|||||||
|
|
||||||
---
|
---
|
||||||
*Roadmap created: 2026-03-12*
|
*Roadmap created: 2026-03-12*
|
||||||
*Last updated: 2026-03-16*
|
### Phase 11 — DataLayer GA4 analytics fix
|
||||||
|
|
||||||
|
**Problem:** Eventy dataLayer ecommerce (purchase, begin_checkout, view_item, add_to_cart) używają starego formatu UA (id/name zamiast item_id/item_name), brak currency w view_item, price:0 w purchase, brak eventu view_cart. Remarketing dynamiczny i konwersje GA4 nie działają poprawnie.
|
||||||
|
|
||||||
|
**Scope:** Poprawka 4 istniejących eventów do formatu GA4 + dodanie nowego eventu view_cart na stronie koszyka.
|
||||||
|
|
||||||
|
**Reference:** `poprawki_datalayer_projectpro.md` — audyt analityki z pomysloweprezenty.pl
|
||||||
|
|
||||||
|
### Phase 12 — summaryView redirect fix
|
||||||
|
|
||||||
|
**Problem:** Po złożeniu pierwszego zamówienia, guard w `summaryView()` sprawdzał sesyjny `order-submit-last-order-id` i redirectował na stronę starego zamówienia. Blokował dostęp do `/koszyk-podsumowanie` dla kolejnych zamówień. Poprawka z instancji klienta (change.md) do wdrożenia globalnie.
|
||||||
|
|
||||||
|
**Scope:** Usunięcie bloku redirect z `summaryView()` w `ShopBasketController.php`. Double-submit protection w `basketSave()` pozostaje bez zmian.
|
||||||
|
|
||||||
|
### Phase 13 — Basket logging + TTL token fix
|
||||||
|
|
||||||
|
**Problem:** Brak logowania w basketSave() uniemożliwia diagnozę błędów zamówień. Token zamówienia jednorazowy — nadpisywany przy każdym wejściu na podsumowanie, co powoduje że druga karta, "wstecz" lub odświeżenie unieważnia formularz.
|
||||||
|
|
||||||
|
**Scope:** Dodanie metody logOrder() z 4 punktami logowania, zmiana tokena z jednorazowego na TTL 30 min, redirect przy błędzie tokena na /koszyk-podsumowanie zamiast /koszyk, nowy double-submit guard.
|
||||||
|
|
||||||
|
### Phase 14 — Custom fields delete bug
|
||||||
|
|
||||||
|
**Problem:** Usunięcie WSZYSTKICH dodatkowych pól z produktu nie działa. jQuery `.serialize()` nie wysyła klucza `custom_field_name[]` gdy nie ma żadnych pól → `array_key_exists('custom_field_name', $d)` w ProductRepository zwraca false → `saveCustomFields()` nigdy nie jest wywoływany → pola pozostają w bazie.
|
||||||
|
|
||||||
|
**Scope:** Dodanie hidden markera `custom_field_name_present` w szablonie JS + zmiana warunku w ProductRepository na sprawdzanie tego markera. Test jednostkowy.
|
||||||
|
|
||||||
|
---
|
||||||
|
*Last updated: 2026-04-16*
|
||||||
|
|||||||
@@ -5,25 +5,25 @@
|
|||||||
See: .paul/PROJECT.md (updated 2026-03-12)
|
See: .paul/PROJECT.md (updated 2026-03-12)
|
||||||
|
|
||||||
**Core value:** Właściciel sklepu ma pełną kontrolę nad sprzedażą online w jednym systemie pisanym od podstaw, bez narzutów zewnętrznych platform.
|
**Core value:** Właściciel sklepu ma pełną kontrolę nad sprzedażą online w jednym systemie pisanym od podstaw, bez narzutów zewnętrznych platform.
|
||||||
**Current focus:** Hotfix Apilo — COMPLETE
|
**Current focus:** Phase 14 complete — custom fields delete bug fix
|
||||||
|
|
||||||
## Current Position
|
## Current Position
|
||||||
|
|
||||||
Milestone: Hotfix — Apilo orders not sending
|
Milestone: Hotfix
|
||||||
Phase: 8 — Diagnoza i naprawa wysyłki zamówień do Apilo — Complete
|
Phase: 14 — custom fields delete bug — Complete
|
||||||
Plan: 08-01 complete (phase done)
|
Plan: 14-01 complete
|
||||||
Status: UNIFY complete, phase 8 finished
|
Status: UNIFY complete, phase 14 finished
|
||||||
Last activity: 2026-03-16 — 08-01 UNIFY complete
|
Last activity: 2026-04-16 — 14-01 UNIFY complete
|
||||||
|
|
||||||
Progress:
|
Progress:
|
||||||
- Phase 8: [██████████] 100% (COMPLETE)
|
- Phase 14: [██████████] 100% (COMPLETE)
|
||||||
|
|
||||||
## Loop Position
|
## Loop Position
|
||||||
|
|
||||||
Current loop state (phase 8, plan 01):
|
Current loop state (phase 14, plan 01):
|
||||||
```
|
```
|
||||||
PLAN ──▶ APPLY ──▶ UNIFY
|
PLAN ──▶ APPLY ──▶ UNIFY
|
||||||
✓ ✓ ✓ [Phase 8 complete]
|
✓ ✓ ✓ [Phase 14 complete]
|
||||||
```
|
```
|
||||||
|
|
||||||
Previous phases:
|
Previous phases:
|
||||||
@@ -33,6 +33,12 @@ Phase 5: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-0
|
|||||||
Phase 6: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-12]
|
Phase 6: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-12]
|
||||||
Phase 7: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-15]
|
Phase 7: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-15]
|
||||||
Phase 8: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-16]
|
Phase 8: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-16]
|
||||||
|
Phase 9: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-19]
|
||||||
|
Phase 10: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-19]
|
||||||
|
Phase 11: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-25]
|
||||||
|
Phase 12: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-25]
|
||||||
|
Phase 13: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-03-25]
|
||||||
|
Phase 14: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-04-16]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Accumulated Context
|
## Accumulated Context
|
||||||
@@ -42,6 +48,19 @@ Phase 8: PLAN ──▶ APPLY ──▶ UNIFY ✓ ✓ ✓ [COMPLETE — 2026-0
|
|||||||
- 2026-03-16: Przyczyna braku wysyłki = brakujące $apiloRepository w use() closures cron.php (regresja z fazy 6)
|
- 2026-03-16: Przyczyna braku wysyłki = brakujące $apiloRepository w use() closures cron.php (regresja z fazy 6)
|
||||||
- 2026-03-16: Retry -1 orders co 1h zamiast permanent failure
|
- 2026-03-16: Retry -1 orders co 1h zamiast permanent failure
|
||||||
- 2026-03-16: Email notification o trwale failed Apilo jobach
|
- 2026-03-16: Email notification o trwale failed Apilo jobach
|
||||||
|
- 2026-03-19: Order-related Apilo joby — infinite retry co 30 min (nigdy permanent failure)
|
||||||
|
- 2026-03-19: Email z danymi zamówienia + rozróżnienie PONAWIANY vs TRWAŁY BŁĄD
|
||||||
|
- 2026-03-19: Cleanup stuck sync_payment/sync_status jobów po udanym wysłaniu
|
||||||
|
- 2026-03-19: Edycja custom fields w koszyku — product_code przeliczany po zmianie, merge duplikatów przy identycznym hashu
|
||||||
|
- 2026-03-19: JS handlery koszyka w basket.php (nie basket-details.php) bo basket-details jest AJAX-replaceable
|
||||||
|
- 2026-03-25: view_cart event w basket.php (nie basket-details.php) — ten sam powód
|
||||||
|
- 2026-03-25: GA4 item format standard: item_id (string), item_name, price (number), quantity (int), google_business_vertical: "retail"
|
||||||
|
- 2026-03-25: Brak user_data w purchase — wymaga analizy RODO
|
||||||
|
- 2026-03-25: summaryView() redirect guard usunięty — blokował kolejne zamówienia po pierwszym (z change.md instancji klienta)
|
||||||
|
- 2026-03-25: Token zamówienia z jednorazowego na TTL 30 min — backward compat z plain string
|
||||||
|
- 2026-03-25: logOrder() — logowanie błędów zamówień do logs/logs-order-YYYY-MM-DD.log
|
||||||
|
- 2026-03-25: Redirect przy złym tokenie: /koszyk-podsumowanie zamiast /koszyk
|
||||||
|
- 2026-04-16: Custom fields delete fix — hidden marker `custom_field_name_present` zamiast `array_key_exists('custom_field_name')`
|
||||||
|
|
||||||
### Deferred Issues
|
### Deferred Issues
|
||||||
None.
|
None.
|
||||||
@@ -51,10 +70,10 @@ None.
|
|||||||
|
|
||||||
## Session Continuity
|
## Session Continuity
|
||||||
|
|
||||||
Last session: 2026-03-16
|
Last session: 2026-04-16
|
||||||
Stopped at: Phase 08 UNIFY complete — Apilo fix loop closed
|
Stopped at: Phase 14 UNIFY complete
|
||||||
Next action: Deploy fix to instance, then /paul:progress for next work
|
Next action: /koniec-pracy or next feature
|
||||||
Resume file: .paul/phases/08-apilo-orders-fix/08-01-SUMMARY.md
|
Resume file: .paul/phases/14-custom-fields-delete-bug/14-01-SUMMARY.md
|
||||||
|
|
||||||
---
|
---
|
||||||
*STATE.md — Updated after every significant action*
|
*STATE.md — Updated after every significant action*
|
||||||
|
|||||||
14
.paul/changelog/2026-04-16.md
Normal file
14
.paul/changelog/2026-04-16.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# 2026-04-16
|
||||||
|
|
||||||
|
## Co zrobiono
|
||||||
|
|
||||||
|
- [Phase 14, Plan 01] Fix: usunięcie wszystkich dodatkowych pól produktu nie działało
|
||||||
|
- Dodano hidden marker `custom_field_name_present` w formularzu edycji produktu
|
||||||
|
- Zmieniono warunek w ProductRepository na sprawdzanie markera zamiast obecności tablicy pól
|
||||||
|
- Dodano test jednostkowy testSaveCustomFieldsDeletesAllWhenEmpty
|
||||||
|
|
||||||
|
## Zmienione pliki
|
||||||
|
|
||||||
|
- `autoload/admin/Controllers/ShopProductController.php`
|
||||||
|
- `autoload/Domain/Product/ProductRepository.php`
|
||||||
|
- `tests/Unit/Domain/Product/ProductRepositoryTest.php`
|
||||||
201
.paul/phases/09-apilo-email-fix/09-01-PLAN.md
Normal file
201
.paul/phases/09-apilo-email-fix/09-01-PLAN.md
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
---
|
||||||
|
phase: 09-apilo-email-fix
|
||||||
|
plan: 01
|
||||||
|
type: execute
|
||||||
|
wave: 1
|
||||||
|
depends_on: []
|
||||||
|
files_modified: [cron.php, autoload/Domain/CronJob/CronJobRepository.php, autoload/Domain/CronJob/CronJobType.php]
|
||||||
|
autonomous: true
|
||||||
|
---
|
||||||
|
|
||||||
|
<objective>
|
||||||
|
## Goal
|
||||||
|
1. Wzbogacić email notyfikacji o trwałym błędzie Apilo o czytelne dane zamówienia (numer, klient, kwota)
|
||||||
|
2. Zamówienia Apilo (send_order, sync_payment, sync_status) muszą być ponawiane w nieskończoność co 30 minut
|
||||||
|
3. Email o błędzie nadal wysyłany (jako ostrzeżenie), ale job wraca do pending zamiast permanent failure
|
||||||
|
4. Po udanym wysłaniu zamówienia — czyścimy powiązane failed/pending joby
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
Administrator dostaje email bez informacji o którym zamówieniu chodzi. Dodatkowo, po 10 próbach zamówienie przestaje być synchronizowane — to niedopuszczalne, bo zamówienie musi trafić do Apilo.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
- Zmodyfikowany `cron.php` — lepsza treść emaila + czyszczenie jobów po sukcesie
|
||||||
|
- Zmodyfikowany `CronJobRepository` — obsługa infinite retry
|
||||||
|
- Zmodyfikowany `CronJobType` — stała backoffu 30min dla Apilo
|
||||||
|
</objective>
|
||||||
|
|
||||||
|
<context>
|
||||||
|
## Project Context
|
||||||
|
@.paul/PROJECT.md
|
||||||
|
@.paul/ROADMAP.md
|
||||||
|
|
||||||
|
## Prior Work
|
||||||
|
@.paul/phases/08-apilo-orders-fix/08-01-SUMMARY.md
|
||||||
|
|
||||||
|
## Source Files
|
||||||
|
@cron.php (linie 198-529 — handler APILO_SEND_ORDER, linie 763-781 — email notification)
|
||||||
|
@autoload/Domain/CronJob/CronJobRepository.php (markFailed — linie 131-156)
|
||||||
|
@autoload/Domain/CronJob/CronJobType.php (stałe backoff)
|
||||||
|
</context>
|
||||||
|
|
||||||
|
<acceptance_criteria>
|
||||||
|
|
||||||
|
## AC-1: Email zawiera czytelne dane zamówienia
|
||||||
|
```gherkin
|
||||||
|
Given trwale nieudane zadanie Apilo z payload zawierającym order_id
|
||||||
|
When system wysyła email notyfikacji
|
||||||
|
Then email zawiera: numer zamówienia, dane klienta, datę zamówienia, kwotę
|
||||||
|
And temat emaila zawiera numery zamówień
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-2: Brak order_id w payload nie powoduje błędu
|
||||||
|
```gherkin
|
||||||
|
Given trwale nieudane zadanie Apilo bez order_id w payload (np. apilo_token_keepalive)
|
||||||
|
When system wysyła email notyfikacji
|
||||||
|
Then email wyświetla dane job-a bez sekcji zamówienia, bez błędów
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-3: Joby zamówień Apilo ponawiają się w nieskończoność co 30 minut
|
||||||
|
```gherkin
|
||||||
|
Given job typu apilo_send_order, apilo_sync_payment lub apilo_sync_status
|
||||||
|
When job osiąga max_attempts
|
||||||
|
Then job NIE jest oznaczany jako failed
|
||||||
|
And job wraca do pending ze scheduled_at = now + 30 minut
|
||||||
|
And email ostrzegawczy jest wysyłany (z informacją że job dalej jest ponawiany)
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-4: Inne joby Apilo (token, product sync) nadal mają limit prób
|
||||||
|
```gherkin
|
||||||
|
Given job typu apilo_token_keepalive lub apilo_product_sync
|
||||||
|
When job osiąga max_attempts
|
||||||
|
Then job jest oznaczany jako failed (zachowanie bez zmian)
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-5: Po udanym wysłaniu zamówienia czyszczone są powiązane failed joby
|
||||||
|
```gherkin
|
||||||
|
Given zamówienie wysłane pomyślnie do Apilo (apilo_order_id ustawiony)
|
||||||
|
When handler APILO_SEND_ORDER kończy się sukcesem
|
||||||
|
Then powiązane joby apilo_sync_payment i apilo_sync_status ze statusem failed
|
||||||
|
zostają usunięte lub anulowane (żeby nie zaśmiecały kolejki)
|
||||||
|
```
|
||||||
|
|
||||||
|
</acceptance_criteria>
|
||||||
|
|
||||||
|
<tasks>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 1: Infinite retry dla order-related Apilo jobów</name>
|
||||||
|
<files>autoload/Domain/CronJob/CronJobType.php, autoload/Domain/CronJob/CronJobRepository.php</files>
|
||||||
|
<action>
|
||||||
|
**CronJobType.php:**
|
||||||
|
1. Dodać stałą `APILO_ORDER_BACKOFF_SECONDS = 1800` (30 minut)
|
||||||
|
2. Dodać statyczną metodę `isOrderRelatedApiloJob($jobType)` zwracającą true dla:
|
||||||
|
- APILO_SEND_ORDER, APILO_SYNC_PAYMENT, APILO_SYNC_STATUS
|
||||||
|
|
||||||
|
**CronJobRepository::markFailed():**
|
||||||
|
3. Przed sprawdzeniem `$attempts >= $maxAttempts`:
|
||||||
|
- Pobrać `job_type` z bazy (dodać do selecta w linia 133)
|
||||||
|
- Jeśli `CronJobType::isOrderRelatedApiloJob($jobType)`:
|
||||||
|
- ZAWSZE wracaj do pending (nigdy failed)
|
||||||
|
- Użyj stałego backoffu `APILO_ORDER_BACKOFF_SECONDS` zamiast exponential
|
||||||
|
- Ustaw `last_error` jak normalnie
|
||||||
|
- Dla pozostałych jobów — logika bez zmian
|
||||||
|
|
||||||
|
UWAGA: Nie zmieniaj sygnatury markFailed() — dodaj job_type do wewnętrznego selecta
|
||||||
|
</action>
|
||||||
|
<verify>
|
||||||
|
1. Przeczytaj kod i zweryfikuj że:
|
||||||
|
- isOrderRelatedApiloJob zwraca true tylko dla 3 typów
|
||||||
|
- markFailed nigdy nie ustawia status=failed dla tych typów
|
||||||
|
- Inne joby zachowują się jak dotychczas
|
||||||
|
2. Uruchom: ./test.ps1 tests/Unit/Domain/CronJob/
|
||||||
|
</verify>
|
||||||
|
<done>AC-3, AC-4 satisfied: Order joby retry w nieskończoność, inne bez zmian</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 2: Lepszy email + ostrzeżenie zamiast trwałego błędu + czyszczenie po sukcesie</name>
|
||||||
|
<files>cron.php</files>
|
||||||
|
<action>
|
||||||
|
**Email notification (linie ~763-781):**
|
||||||
|
1. Zmienić query o failed joby — RÓWNIEŻ szukać order-related jobów w statusie pending z dużą liczbą prób (np. attempts >= 10), żeby wysyłać ostrzeżenie
|
||||||
|
2. Dla każdego job-a: sparsować payload (json_decode jeśli string), wyciągnąć order_id
|
||||||
|
3. Jeśli order_id istnieje — pobrać z pp_shop_orders:
|
||||||
|
- `order_number` (lub `id` jeśli brak), `client_name`/`client_surname`, `date_order`, `total_brutto`
|
||||||
|
4. Sformatować email:
|
||||||
|
```
|
||||||
|
Job #X (apilo_send_order) — PONAWIANY CO 30 MIN
|
||||||
|
Zamówienie: #12345 (ID: 678)
|
||||||
|
Klient: Jan Kowalski
|
||||||
|
Data zamówienia: 2026-03-19 14:30:00
|
||||||
|
Kwota: 199.99 PLN
|
||||||
|
Próby: 15
|
||||||
|
Błąd: [last_error]
|
||||||
|
Ostatnia próba: [updated_at lub scheduled_at]
|
||||||
|
```
|
||||||
|
5. Dla jobów permanent failed (nie-order): zachować stary format "trwały błąd"
|
||||||
|
6. Temat: dodać numery zamówień jeśli dostępne
|
||||||
|
7. Email ma rozróżniać: "PONAWIANY" vs "TRWAŁY BŁĄD" w zależności od typu joba
|
||||||
|
|
||||||
|
**Czyszczenie po sukcesie (w handlerze APILO_SEND_ORDER, po linii ~522-524):**
|
||||||
|
8. Po pomyślnym wysłaniu zamówienia (`apilo_order_id` ustawiony):
|
||||||
|
- Usunąć/anulować failed/pending joby `apilo_sync_payment` i `apilo_sync_status`
|
||||||
|
z payload zawierającym ten sam order_id
|
||||||
|
- Użyć: `$mdb->delete('pp_cron_jobs', [...])` lub update status=cancelled
|
||||||
|
- To zapobiega zaśmiecaniu kolejki starymi retry jobami
|
||||||
|
|
||||||
|
UWAGA:
|
||||||
|
- Nazwy kolumn zamówienia: sprawdź jakie faktycznie są w pp_shop_orders (mogą być polskie)
|
||||||
|
- Payload w bazie to JSON string — json_decode($fj['payload'], true)
|
||||||
|
- Nie zmieniaj logiki wysyłania zamówień — tylko email i cleanup
|
||||||
|
</action>
|
||||||
|
<verify>
|
||||||
|
1. Przeczytaj zmodyfikowany kod
|
||||||
|
2. Zweryfikuj że query do pp_shop_orders używa poprawnych kolumn
|
||||||
|
3. Zweryfikuj brak błędów PHP (null handling, json_decode guard)
|
||||||
|
4. Uruchom: ./test.ps1
|
||||||
|
</verify>
|
||||||
|
<done>AC-1, AC-2, AC-5 satisfied: Email czytelny, cleanup po sukcesie</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
</tasks>
|
||||||
|
|
||||||
|
<boundaries>
|
||||||
|
|
||||||
|
## DO NOT CHANGE
|
||||||
|
- Logikę wysyłania zamówień do Apilo (curl, payload budowanie)
|
||||||
|
- Logikę exponential backoff dla NIE-order jobów
|
||||||
|
- Handlery APILO_SYNC_PAYMENT, APILO_SYNC_STATUS, APILO_STATUS_POLL (poza cleanup)
|
||||||
|
- Odbiorcę emaila i warunki wysyłki (poza rozszerzeniem query)
|
||||||
|
- Tabelę pp_shop_orders — żadnych nowych kolumn
|
||||||
|
|
||||||
|
## SCOPE LIMITS
|
||||||
|
- Tylko retry logic, email formatting, i cleanup
|
||||||
|
- Nie dodawać nowych tabel
|
||||||
|
- Nie zmieniać enqueue() ani fetchNext()
|
||||||
|
|
||||||
|
</boundaries>
|
||||||
|
|
||||||
|
<verification>
|
||||||
|
Before declaring plan complete:
|
||||||
|
- [ ] Order-related Apilo joby nigdy nie dostają status=failed
|
||||||
|
- [ ] Backoff dla order jobów = stałe 30 min
|
||||||
|
- [ ] Inne joby zachowują stare zachowanie (exponential, max 10)
|
||||||
|
- [ ] Email zawiera numer zamówienia gdy dostępny
|
||||||
|
- [ ] Email rozróżnia "ponawiany" vs "trwały błąd"
|
||||||
|
- [ ] Po sukcesie wysyłki czyścimy related joby
|
||||||
|
- [ ] Brak błędów PHP
|
||||||
|
- [ ] Testy przechodzą (./test.ps1)
|
||||||
|
- [ ] All acceptance criteria met
|
||||||
|
</verification>
|
||||||
|
|
||||||
|
<success_criteria>
|
||||||
|
- Zamówienia Apilo są ponawiane w nieskończoność co 30 min
|
||||||
|
- Email notyfikacji zawiera czytelne dane zamówienia
|
||||||
|
- Po udanym wysłaniu czyszczone są stare joby
|
||||||
|
- Zero regresji w testach
|
||||||
|
</success_criteria>
|
||||||
|
|
||||||
|
<output>
|
||||||
|
After completion, create `.paul/phases/09-apilo-email-fix/09-01-SUMMARY.md`
|
||||||
|
</output>
|
||||||
111
.paul/phases/09-apilo-email-fix/09-01-SUMMARY.md
Normal file
111
.paul/phases/09-apilo-email-fix/09-01-SUMMARY.md
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
---
|
||||||
|
phase: 09-apilo-email-fix
|
||||||
|
plan: 01
|
||||||
|
subsystem: integrations
|
||||||
|
tags: [apilo, cron, email, retry]
|
||||||
|
|
||||||
|
requires:
|
||||||
|
- phase: 08-apilo-orders-fix
|
||||||
|
provides: cron job system, Apilo email notification
|
||||||
|
provides:
|
||||||
|
- Infinite retry dla order-related Apilo jobów (30 min interval)
|
||||||
|
- Email notyfikacji z danymi zamówienia (numer, klient, kwota)
|
||||||
|
- Cleanup starych jobów po udanym wysłaniu
|
||||||
|
affects: []
|
||||||
|
|
||||||
|
tech-stack:
|
||||||
|
added: []
|
||||||
|
patterns:
|
||||||
|
- "isOrderRelatedApiloJob() — centralna identyfikacja order jobów Apilo"
|
||||||
|
- "Infinite retry pattern — stały backoff zamiast exponential dla krytycznych jobów"
|
||||||
|
|
||||||
|
key-files:
|
||||||
|
modified:
|
||||||
|
- autoload/Domain/CronJob/CronJobType.php
|
||||||
|
- autoload/Domain/CronJob/CronJobRepository.php
|
||||||
|
- cron.php
|
||||||
|
|
||||||
|
key-decisions:
|
||||||
|
- "Order joby Apilo nigdy nie failują trwale — infinite retry co 30 min"
|
||||||
|
- "Email rozróżnia PONAWIANY vs TRWAŁY BŁĄD"
|
||||||
|
- "Po udanym wysłaniu zamówienia czyszczone są stuck joby sync_payment/sync_status"
|
||||||
|
|
||||||
|
duration: ~15min
|
||||||
|
completed: 2026-03-19
|
||||||
|
---
|
||||||
|
|
||||||
|
# Phase 9 Plan 01: Apilo email fix + infinite retry — Summary
|
||||||
|
|
||||||
|
**Email notyfikacji Apilo wzbogacony o dane zamówienia (numer, klient, kwota) + order joby ponawiane w nieskończoność co 30 min zamiast permanent failure po 10 próbach.**
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
| Metric | Value |
|
||||||
|
|--------|-------|
|
||||||
|
| Duration | ~15 min |
|
||||||
|
| Completed | 2026-03-19 |
|
||||||
|
| Tasks | 2 completed |
|
||||||
|
| Files modified | 4 (+ 1 test file) |
|
||||||
|
| Tests | 820 passed, 2277 assertions |
|
||||||
|
|
||||||
|
## Acceptance Criteria Results
|
||||||
|
|
||||||
|
| Criterion | Status | Notes |
|
||||||
|
|-----------|--------|-------|
|
||||||
|
| AC-1: Email zawiera dane zamówienia | Pass | Numer, klient, data, kwota z pp_shop_orders |
|
||||||
|
| AC-2: Brak order_id nie powoduje błędu | Pass | Graceful handling — pokazuje tylko dane joba |
|
||||||
|
| AC-3: Order joby retry co 30 min w nieskończoność | Pass | isOrderRelatedApiloJob() + stały backoff 1800s |
|
||||||
|
| AC-4: Inne joby zachowują limit prób | Pass | Testy potwierdzają — price_history nadal failuje po max_attempts |
|
||||||
|
| AC-5: Cleanup po udanym wysłaniu | Pass | delete stuck sync_payment/sync_status jobów |
|
||||||
|
|
||||||
|
## Accomplishments
|
||||||
|
|
||||||
|
- Order-related Apilo joby (send_order, sync_payment, sync_status) nigdy nie wpadają w permanent failure — zawsze wracają do pending co 30 min
|
||||||
|
- Email notyfikacji zawiera czytelne dane zamówienia zamiast surowego JSON payload
|
||||||
|
- Temat emaila zawiera numery zamówień dla szybkiej identyfikacji
|
||||||
|
- Email rozróżnia "PONAWIANY CO 30 MIN" vs "TRWAŁY BŁĄD" w zależności od typu joba
|
||||||
|
- Po udanym wysłaniu zamówienia do Apilo czyszczone są stare stuck joby sync_payment/sync_status
|
||||||
|
|
||||||
|
## Files Created/Modified
|
||||||
|
|
||||||
|
| File | Change | Purpose |
|
||||||
|
|------|--------|---------|
|
||||||
|
| `autoload/Domain/CronJob/CronJobType.php` | Modified | +APILO_ORDER_BACKOFF_SECONDS (1800s), +isOrderRelatedApiloJob() |
|
||||||
|
| `autoload/Domain/CronJob/CronJobRepository.php` | Modified | markFailed() — infinite retry dla order jobów |
|
||||||
|
| `cron.php` | Modified | Email z danymi zamówienia + cleanup po sukcesie |
|
||||||
|
| `tests/Unit/Domain/CronJob/CronJobRepositoryTest.php` | Modified | +2 testy infinite retry, fix mocków z job_type |
|
||||||
|
|
||||||
|
## Decisions Made
|
||||||
|
|
||||||
|
| Decision | Rationale | Impact |
|
||||||
|
|----------|-----------|--------|
|
||||||
|
| Stały backoff 1800s zamiast exponential | Zamówienia muszą trafić do Apilo — przewidywalny interwał ważniejszy niż agresywny retry | Order joby ponawiane regularnie co 30 min |
|
||||||
|
| Email ostrzegawczy zamiast "trwały błąd" | Order joby nigdy nie failują trwale, ale admin musi wiedzieć o problemie | Zmieniony temat i treść emaila |
|
||||||
|
| Cleanup starych jobów po sukcesie | Zapobieganie zaśmiecaniu kolejki stuck jobami sync_payment/sync_status | Delete zamiast cancel — prostsze |
|
||||||
|
|
||||||
|
## Deviations from Plan
|
||||||
|
|
||||||
|
None — plan executed as written.
|
||||||
|
|
||||||
|
## Issues Encountered
|
||||||
|
|
||||||
|
| Issue | Resolution |
|
||||||
|
|-------|------------|
|
||||||
|
| Testy CronJob failowały — mock get() nie zwracał job_type | Dodano job_type do willReturn() w 3 istniejących testach |
|
||||||
|
| test.ps1 nie istnieje | Użyto bezpośrednio `php phpunit.phar` |
|
||||||
|
|
||||||
|
## Next Phase Readiness
|
||||||
|
|
||||||
|
**Ready:**
|
||||||
|
- System retry Apilo jest kompletny i odporny na awarie
|
||||||
|
- Email notyfikacji daje adminowi pełen kontekst do szybkiej reakcji
|
||||||
|
|
||||||
|
**Concerns:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
**Blockers:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
---
|
||||||
|
*Phase: 09-apilo-email-fix, Plan: 01*
|
||||||
|
*Completed: 2026-03-19*
|
||||||
221
.paul/phases/10-basket-edit-custom-fields/10-01-PLAN.md
Normal file
221
.paul/phases/10-basket-edit-custom-fields/10-01-PLAN.md
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
---
|
||||||
|
phase: 10-basket-edit-custom-fields
|
||||||
|
plan: 01
|
||||||
|
type: execute
|
||||||
|
wave: 1
|
||||||
|
depends_on: []
|
||||||
|
files_modified:
|
||||||
|
- autoload/front/Controllers/ShopBasketController.php
|
||||||
|
- templates/shop-basket/_partials/product-custom-fields.php
|
||||||
|
- templates/shop-basket/basket-details.php
|
||||||
|
- ajax.php
|
||||||
|
autonomous: true
|
||||||
|
---
|
||||||
|
|
||||||
|
<objective>
|
||||||
|
## Goal
|
||||||
|
Dodać możliwość edycji personalizacji (custom fields) produktu bezpośrednio w koszyku, bez konieczności usuwania produktu i dodawania go od nowa.
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
Klient, który pomyli się przy wpisywaniu personalizacji (np. grawer, dedykacja), musi teraz usunąć produkt z koszyka i dodać go ponownie z poprawnymi danymi. To frustrujące UX — edycja inline jest naturalnym oczekiwaniem.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
- Przycisk "Edytuj" przy personalizacjach w koszyku
|
||||||
|
- Modal lub formularz inline do edycji wartości custom fields
|
||||||
|
- Endpoint AJAX do zapisania zmian w sesji koszyka
|
||||||
|
- Przeliczenie product_code (MD5 hash) po zmianie wartości
|
||||||
|
</objective>
|
||||||
|
|
||||||
|
<context>
|
||||||
|
## Project Context
|
||||||
|
@.paul/PROJECT.md
|
||||||
|
@.paul/ROADMAP.md
|
||||||
|
@.paul/STATE.md
|
||||||
|
|
||||||
|
## Source Files
|
||||||
|
@autoload/front/Controllers/ShopBasketController.php
|
||||||
|
@templates/shop-basket/_partials/product-custom-fields.php
|
||||||
|
@templates/shop-basket/basket-details.php
|
||||||
|
@templates/shop-product/_partial/product-custom-fields.php
|
||||||
|
@autoload/Domain/Product/ProductRepository.php
|
||||||
|
@ajax.php
|
||||||
|
</context>
|
||||||
|
|
||||||
|
<skills>
|
||||||
|
## Required Skills (from SPECIAL-FLOWS.md)
|
||||||
|
|
||||||
|
No specialized flows configured — /frontend-design jest optional.
|
||||||
|
|
||||||
|
</skills>
|
||||||
|
|
||||||
|
<acceptance_criteria>
|
||||||
|
|
||||||
|
## AC-1: Przycisk edycji widoczny w koszyku
|
||||||
|
```gherkin
|
||||||
|
Given produkt w koszyku ma wypełnione custom fields (personalizacje)
|
||||||
|
When klient widzi szczegóły koszyka (basket-details)
|
||||||
|
Then przy każdej pozycji z custom fields widnieje przycisk "Edytuj personalizację"
|
||||||
|
And przycisk NIE pojawia się gdy produkt nie ma custom fields
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-2: Formularz edycji wyświetla aktualne wartości
|
||||||
|
```gherkin
|
||||||
|
Given klient klika "Edytuj personalizację" przy pozycji koszyka
|
||||||
|
When otwiera się formularz edycji (modal lub inline)
|
||||||
|
Then formularz zawiera pola odpowiadające custom fields tego produktu
|
||||||
|
And pola są wypełnione aktualnymi wartościami z koszyka
|
||||||
|
And pola wymagane (is_required) są oznaczone jako wymagane
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-3: Zapis zmian aktualizuje koszyk
|
||||||
|
```gherkin
|
||||||
|
Given klient zmienił wartości custom fields w formularzu edycji
|
||||||
|
When klika "Zapisz"
|
||||||
|
Then wartości custom fields w sesji koszyka są zaktualizowane
|
||||||
|
And product_code (MD5 hash) jest przeliczony z nowymi wartościami
|
||||||
|
And strona koszyka odświeża się pokazując nowe wartości
|
||||||
|
And ilość produktu i inne atrybuty nie ulegają zmianie
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-4: Walidacja pól wymaganych
|
||||||
|
```gherkin
|
||||||
|
Given produkt ma custom field oznaczone jako is_required = 1
|
||||||
|
When klient próbuje zapisać formularz z pustym polem wymaganym
|
||||||
|
Then zapis jest blokowany
|
||||||
|
And wyświetlany jest komunikat o wymaganym polu
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-5: Obsługa konfliktu duplikatu
|
||||||
|
```gherkin
|
||||||
|
Given koszyk zawiera dwa egzemplarze tego samego produktu z różnymi personalizacjami
|
||||||
|
When klient edytuje personalizację jednego tak, że staje się identyczna z drugim
|
||||||
|
Then pozycje zostają scalone (ilości zsumowane)
|
||||||
|
And w koszyku pozostaje jedna pozycja z łączną ilością
|
||||||
|
```
|
||||||
|
|
||||||
|
</acceptance_criteria>
|
||||||
|
|
||||||
|
<tasks>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 1: Endpoint AJAX do aktualizacji custom fields w koszyku</name>
|
||||||
|
<files>autoload/front/Controllers/ShopBasketController.php, ajax.php</files>
|
||||||
|
<action>
|
||||||
|
Dodać metodę `basketUpdateCustomFields()` w ShopBasketController:
|
||||||
|
|
||||||
|
1. Przyjmuje POST z parametrami:
|
||||||
|
- `product_code` — obecny klucz pozycji w koszyku (MD5 hash)
|
||||||
|
- `custom_field[ID]` — nowe wartości custom fields (tablica)
|
||||||
|
|
||||||
|
2. Logika metody:
|
||||||
|
- Pobierz pozycję koszyka po `product_code` z sesji
|
||||||
|
- Jeśli nie istnieje → zwróć błąd JSON
|
||||||
|
- Waliduj wymagane pola (pobierz metadane z ProductRepository::findCustomFieldCached)
|
||||||
|
- Jeśli walidacja nie przejdzie → zwróć błąd JSON z listą brakujących pól
|
||||||
|
- Zaktualizuj `custom_fields` w pozycji koszyka
|
||||||
|
- Przelicz nowy product_code: `md5(product_id . attributes . message . json_encode(new_custom_fields))`
|
||||||
|
- Jeśli nowy product_code == stary → tylko aktualizuj wartości
|
||||||
|
- Jeśli nowy product_code istnieje już w koszyku → scal pozycje (zsumuj ilość), usuń starą
|
||||||
|
- Jeśli nowy product_code nie istnieje → przenieś pozycję pod nowy klucz, usuń stary
|
||||||
|
- Przelicz sumę koszyka
|
||||||
|
- Zwróć JSON success
|
||||||
|
|
||||||
|
3. Zarejestruj endpoint w ajax.php pod kluczem `basket_update_custom_fields`
|
||||||
|
- Wzoruj się na istniejących endpointach koszyka (basket_add_product, basket_remove itp.)
|
||||||
|
|
||||||
|
Unikaj:
|
||||||
|
- NIE używaj match expressions (PHP < 8.0)
|
||||||
|
- NIE sklejaj SQL stringiem — custom fields są w sesji, nie w DB
|
||||||
|
- Escape wartości przy wyświetlaniu (htmlspecialchars), ale w sesji przechowuj surowe wartości
|
||||||
|
</action>
|
||||||
|
<verify>
|
||||||
|
Testy PHPUnit przechodzą (php phpunit.phar).
|
||||||
|
Endpoint odpowiada na POST z prawidłowym JSON response.
|
||||||
|
</verify>
|
||||||
|
<done>AC-3, AC-4, AC-5 satisfied: endpoint aktualizuje custom fields, waliduje required, obsługuje merge duplikatów</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 2: UI edycji personalizacji w szablonie koszyka</name>
|
||||||
|
<files>templates/shop-basket/_partials/product-custom-fields.php, templates/shop-basket/basket-details.php</files>
|
||||||
|
<action>
|
||||||
|
1. W `product-custom-fields.php` dodać przycisk "Edytuj personalizację":
|
||||||
|
- Przycisk widoczny tylko gdy `$this->custom_fields` nie jest puste
|
||||||
|
- Atrybut data-product-code z kluczem pozycji koszyka
|
||||||
|
- Klasa CSS do stylowania (np. `btn-edit-custom-fields`)
|
||||||
|
|
||||||
|
2. Dodać ukryty formularz edycji (modal inline) pod przyciskiem:
|
||||||
|
- Dla każdego custom field: input z aktualną wartością
|
||||||
|
- Pola wymagane oznaczone `required` + wizualnie (gwiazdka)
|
||||||
|
- Typ pola (text/image) z metadanych custom field
|
||||||
|
- Przyciski "Zapisz" i "Anuluj"
|
||||||
|
- Formularz domyślnie ukryty (`display: none`)
|
||||||
|
|
||||||
|
3. W `basket-details.php` dodać JavaScript obsługujący:
|
||||||
|
- Klik "Edytuj" → pokaż formularz, ukryj wyświetlane wartości
|
||||||
|
- Klik "Anuluj" → ukryj formularz, pokaż wartości
|
||||||
|
- Klik "Zapisz" → AJAX POST do `basket_update_custom_fields`
|
||||||
|
- Walidacja client-side required fields przed wysłaniem
|
||||||
|
- Po sukcesie → przeładuj stronę koszyka (location.reload)
|
||||||
|
- Po błędzie → pokaż komunikat
|
||||||
|
|
||||||
|
4. Przekazać `product_code` do szablonu custom fields:
|
||||||
|
- W `basket-details.php` przy wywołaniu `Tpl::view('shop-basket/_partials/product-custom-fields', ...)`
|
||||||
|
dodać parametr `product_code` z kluczem pozycji
|
||||||
|
|
||||||
|
Unikaj:
|
||||||
|
- NIE dodawaj zewnętrznych bibliotek JS/CSS
|
||||||
|
- NIE zmieniaj struktury HTML istniejących elementów (dodawaj nowe)
|
||||||
|
- Escape wszystkich wartości w atrybutach HTML (htmlspecialchars)
|
||||||
|
- NIE używaj str_contains/str_starts_with (PHP 8.0+)
|
||||||
|
</action>
|
||||||
|
<verify>
|
||||||
|
Wizualna weryfikacja: przycisk "Edytuj" widoczny w koszyku przy produktach z personalizacją.
|
||||||
|
Klik otwiera formularz z aktualnymi wartościami.
|
||||||
|
Zapis odświeża koszyk z nowymi wartościami.
|
||||||
|
</verify>
|
||||||
|
<done>AC-1, AC-2 satisfied: przycisk edycji widoczny, formularz wyświetla aktualne wartości</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
</tasks>
|
||||||
|
|
||||||
|
<boundaries>
|
||||||
|
|
||||||
|
## DO NOT CHANGE
|
||||||
|
- autoload/Domain/Product/ProductRepository.php (nie modyfikuj metod findCustomFieldCached, saveCustomFields)
|
||||||
|
- autoload/Domain/Order/OrderRepository.php (nie zmieniaj createFromBasket)
|
||||||
|
- templates/shop-product/ (szablony strony produktu bez zmian)
|
||||||
|
- autoload/Domain/Basket/BasketRepository.php (jeśli istnieje — nie modyfikuj)
|
||||||
|
|
||||||
|
## SCOPE LIMITS
|
||||||
|
- Tylko koszyk (basket-details) — NIE podsumowanie zamówienia (summary-view)
|
||||||
|
- Tylko edycja wartości — NIE dodawanie/usuwanie pól custom fields
|
||||||
|
- Tylko pola typu text i image — nie dodawaj nowych typów pól
|
||||||
|
- NIE zmieniaj sposobu przechowywania custom fields w zamówieniach (pp_shop_order_products)
|
||||||
|
- NIE dodawaj testów PHPUnit dla warstwy widoku (templates) — testuj tylko logikę kontrolera
|
||||||
|
|
||||||
|
</boundaries>
|
||||||
|
|
||||||
|
<verification>
|
||||||
|
Before declaring plan complete:
|
||||||
|
- [ ] `php phpunit.phar` — wszystkie testy przechodzą (820+)
|
||||||
|
- [ ] Endpoint `basket_update_custom_fields` zwraca poprawny JSON
|
||||||
|
- [ ] Przycisk "Edytuj" widoczny w koszyku przy produktach z personalizacją
|
||||||
|
- [ ] Formularz edycji wyświetla aktualne wartości
|
||||||
|
- [ ] Zapis zmienia wartości w sesji i odświeża koszyk
|
||||||
|
- [ ] Pola required są walidowane (client + server side)
|
||||||
|
- [ ] Merge duplikatów działa poprawnie
|
||||||
|
- [ ] Brak regresji — istniejąca funkcjonalność koszyka działa bez zmian
|
||||||
|
</verification>
|
||||||
|
|
||||||
|
<success_criteria>
|
||||||
|
- Wszystkie testy PHPUnit przechodzą
|
||||||
|
- AC-1 do AC-5 spełnione
|
||||||
|
- Kod zgodny z PHP < 8.0
|
||||||
|
- XSS protection (htmlspecialchars) na wszystkich outputach
|
||||||
|
- Brak nowych zależności zewnętrznych
|
||||||
|
</success_criteria>
|
||||||
|
|
||||||
|
<output>
|
||||||
|
After completion, create `.paul/phases/10-basket-edit-custom-fields/10-01-SUMMARY.md`
|
||||||
|
</output>
|
||||||
114
.paul/phases/10-basket-edit-custom-fields/10-01-SUMMARY.md
Normal file
114
.paul/phases/10-basket-edit-custom-fields/10-01-SUMMARY.md
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
---
|
||||||
|
phase: 10-basket-edit-custom-fields
|
||||||
|
plan: 01
|
||||||
|
subsystem: ui
|
||||||
|
tags: [basket, custom-fields, personalization, ajax, session]
|
||||||
|
|
||||||
|
requires:
|
||||||
|
- phase: none
|
||||||
|
provides: existing basket/custom fields infrastructure
|
||||||
|
|
||||||
|
provides:
|
||||||
|
- Edycja personalizacji produktu w koszyku (inline form + AJAX endpoint)
|
||||||
|
- Merge duplikatów przy identycznym product_code po edycji
|
||||||
|
|
||||||
|
affects: []
|
||||||
|
|
||||||
|
tech-stack:
|
||||||
|
added: []
|
||||||
|
patterns: [inline edit form with toggle display/edit, product_code recalculation]
|
||||||
|
|
||||||
|
key-files:
|
||||||
|
created: []
|
||||||
|
modified:
|
||||||
|
- autoload/front/Controllers/ShopBasketController.php
|
||||||
|
- templates/shop-basket/_partials/product-custom-fields.php
|
||||||
|
- templates/shop-basket/basket-details.php
|
||||||
|
- templates/shop-basket/basket.php
|
||||||
|
|
||||||
|
key-decisions:
|
||||||
|
- "Formularz inline zamiast modala — prostsze, bez dodatkowych zależności"
|
||||||
|
- "JS w basket.php zamiast basket-details.php — delegowane eventy działają po przeładowaniu AJAX"
|
||||||
|
- "ajax.php nie wymaga zmian — routing automatyczny przez front\\App"
|
||||||
|
|
||||||
|
patterns-established:
|
||||||
|
- "Toggle display/edit z data-product-code jako identyfikator"
|
||||||
|
|
||||||
|
duration: ~15min
|
||||||
|
started: 2026-03-19T13:40:00Z
|
||||||
|
completed: 2026-03-19T13:55:00Z
|
||||||
|
---
|
||||||
|
|
||||||
|
# Phase 10 Plan 01: Edycja personalizacji produktu w koszyku — Summary
|
||||||
|
|
||||||
|
**Klient może edytować personalizacje (custom fields) produktu bezpośrednio w koszyku bez usuwania i ponownego dodawania.**
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
| Metric | Value |
|
||||||
|
|--------|-------|
|
||||||
|
| Duration | ~15 min |
|
||||||
|
| Tasks | 2 completed |
|
||||||
|
| Files modified | 4 |
|
||||||
|
| Tests | 820 passed, 0 failures |
|
||||||
|
|
||||||
|
## Acceptance Criteria Results
|
||||||
|
|
||||||
|
| Criterion | Status | Notes |
|
||||||
|
|-----------|--------|-------|
|
||||||
|
| AC-1: Przycisk edycji widoczny | Pass | Przycisk "Edytuj personalizację" przy pozycjach z custom fields, ukryty gdy brak |
|
||||||
|
| AC-2: Formularz z aktualnymi wartościami | Pass | Inline form z wypełnionymi wartościami, required oznaczone gwiazdką |
|
||||||
|
| AC-3: Zapis aktualizuje koszyk | Pass | AJAX POST → przeliczenie hash → reload strony |
|
||||||
|
| AC-4: Walidacja required | Pass | Client-side (input required + alert) + server-side (findCustomFieldCached + is_required check) |
|
||||||
|
| AC-5: Merge duplikatów | Pass | Gdy nowy hash == istniejący → sumowanie quantity, usunięcie starej pozycji |
|
||||||
|
|
||||||
|
## Accomplishments
|
||||||
|
|
||||||
|
- Endpoint `basketUpdateCustomFields()` w ShopBasketController z pełną logiką: walidacja, hash recalculation, merge
|
||||||
|
- UI: toggle display↔edit z formularzem inline, walidacja client-side
|
||||||
|
- XSS protection na wszystkich outputach (htmlspecialchars)
|
||||||
|
- Kompatybilność PHP < 8.0 (brak match, str_contains, union types)
|
||||||
|
|
||||||
|
## Files Created/Modified
|
||||||
|
|
||||||
|
| File | Change | Purpose |
|
||||||
|
|------|--------|---------|
|
||||||
|
| `autoload/front/Controllers/ShopBasketController.php` | Modified | Nowa metoda `basketUpdateCustomFields()` — AJAX endpoint |
|
||||||
|
| `templates/shop-basket/_partials/product-custom-fields.php` | Modified | Wyświetlanie + formularz edycji z toggle |
|
||||||
|
| `templates/shop-basket/basket-details.php` | Modified | Przekazanie `product_code` do szablonu custom fields |
|
||||||
|
| `templates/shop-basket/basket.php` | Modified | JavaScript: edycja, anulowanie, zapis AJAX |
|
||||||
|
|
||||||
|
## Deviations from Plan
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
| Type | Count | Impact |
|
||||||
|
|------|-------|--------|
|
||||||
|
| Scope change | 2 | Minimalne — lepsze dopasowanie do architektury |
|
||||||
|
|
||||||
|
**Total impact:** Drobne odchylenia, brak wpływu na funkcjonalność.
|
||||||
|
|
||||||
|
### Details
|
||||||
|
|
||||||
|
1. **ajax.php nie zmodyfikowany** — plan zakładał rejestrację endpointu w ajax.php, ale routing `/shopBasket/basket_update_custom_fields` działa automatycznie przez `front\App::route()` → konwersja snake_case → camelCase → `ShopBasketController::basketUpdateCustomFields()`. Zmiana w ajax.php była niepotrzebna.
|
||||||
|
|
||||||
|
2. **JS w basket.php zamiast basket-details.php** — plan wskazywał basket-details.php, ale ten szablon jest przeładowywany AJAX-em (innerHTML replacement). Delegowane eventy muszą być w basket.php który jest stały. Wszystkie inne handlery koszyka (remove, increase, decrease) też są w basket.php.
|
||||||
|
|
||||||
|
## Issues Encountered
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
## Next Phase Readiness
|
||||||
|
|
||||||
|
**Ready:**
|
||||||
|
- Edycja personalizacji w koszyku gotowa do testów manualnych na produkcji
|
||||||
|
|
||||||
|
**Concerns:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
**Blockers:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
---
|
||||||
|
*Phase: 10-basket-edit-custom-fields, Plan: 01*
|
||||||
|
*Completed: 2026-03-19*
|
||||||
225
.paul/phases/11-datalayer-ga4-fix/11-01-PLAN.md
Normal file
225
.paul/phases/11-datalayer-ga4-fix/11-01-PLAN.md
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
---
|
||||||
|
phase: 11-datalayer-ga4-fix
|
||||||
|
plan: 01
|
||||||
|
type: execute
|
||||||
|
wave: 1
|
||||||
|
depends_on: []
|
||||||
|
files_modified:
|
||||||
|
- templates/shop-order/order-details.php
|
||||||
|
- templates/shop-basket/summary-view.php
|
||||||
|
- templates/shop-product/product.php
|
||||||
|
- templates/shop-basket/basket.php
|
||||||
|
autonomous: true
|
||||||
|
---
|
||||||
|
|
||||||
|
<objective>
|
||||||
|
## Goal
|
||||||
|
Naprawic wszystkie eventy dataLayer ecommerce (purchase, begin_checkout, view_item, add_to_cart) do formatu GA4 oraz dodac brakujacy event view_cart. Poprawki krytyczne dla remarketingu dynamicznego i konwersji.
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
Bez tych poprawek remarketing dynamiczny Google Ads i konwersje GA4 nie dzialaja poprawnie — ceny produktow sa zerowe, klucze itemow niezgodne z GA4, brakuje walut i eventow.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
Poprawione 4 szablony PHP z prawidlowymi eventami dataLayer GA4.
|
||||||
|
</objective>
|
||||||
|
|
||||||
|
<context>
|
||||||
|
## Project Context
|
||||||
|
@.paul/PROJECT.md
|
||||||
|
@.paul/ROADMAP.md
|
||||||
|
@.paul/STATE.md
|
||||||
|
|
||||||
|
## Source Files
|
||||||
|
@templates/shop-order/order-details.php (purchase event, lines 164-192)
|
||||||
|
@templates/shop-basket/summary-view.php (begin_checkout event, lines 72-80, 175-187)
|
||||||
|
@templates/shop-product/product.php (view_item lines 273-288, add_to_cart lines 607-625)
|
||||||
|
@templates/shop-basket/basket.php (brak view_cart — do dodania)
|
||||||
|
|
||||||
|
## Technical Reference
|
||||||
|
@poprawki_datalayer_projectpro.md (specyfikacja zmian z audytu)
|
||||||
|
|
||||||
|
## Data Model
|
||||||
|
Order products (pp_shop_order_products) mają kolumny: product_id, name, price_brutto, price_brutto_promo, quantity.
|
||||||
|
Basket products — surowa tablica z sesji, product data fetchowana przez ProductRepository::findCached().
|
||||||
|
</context>
|
||||||
|
|
||||||
|
<skills>
|
||||||
|
No specialized flows configured — standard execute plan.
|
||||||
|
</skills>
|
||||||
|
|
||||||
|
<acceptance_criteria>
|
||||||
|
|
||||||
|
## AC-1: Purchase event — format GA4 z prawidlowa cena
|
||||||
|
```gherkin
|
||||||
|
Given strona potwierdzenia zamowienia /zamowienie/*
|
||||||
|
When dataLayer.push(purchase) jest wywolany
|
||||||
|
Then items maja klucze item_id (string), item_name, price (number > 0), quantity (number), google_business_vertical: "retail"
|
||||||
|
And ecommerce ma currency: "PLN"
|
||||||
|
And nie ma zduplikowanego klucza value ani hardcoded wartosci
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-2: Begin_checkout event — format GA4
|
||||||
|
```gherkin
|
||||||
|
Given strona /koszyk-podsumowanie z produktami w koszyku
|
||||||
|
When dataLayer.push(begin_checkout) jest wywolany
|
||||||
|
Then items maja klucze item_id (string), item_name (zamiast id, name), price (number), quantity (number), google_business_vertical: "retail"
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-3: View_item event — kompletne dane
|
||||||
|
```gherkin
|
||||||
|
Given strona produktu
|
||||||
|
When dataLayer.push(view_item) jest wywolany
|
||||||
|
Then ecommerce zawiera currency: "PLN" i value (number)
|
||||||
|
And items maja price jako number (nie string), google_business_vertical: "retail"
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-4: Add_to_cart event — poprawne typy
|
||||||
|
```gherkin
|
||||||
|
Given klikniecie "dodaj do koszyka" na stronie produktu
|
||||||
|
When dataLayer.push(add_to_cart) jest wywolany
|
||||||
|
Then items maja google_business_vertical: "retail"
|
||||||
|
And quantity jest number (nie string)
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-5: View_cart event — nowy event na stronie koszyka
|
||||||
|
```gherkin
|
||||||
|
Given strona /koszyk z produktami w koszyku
|
||||||
|
When strona sie zaladuje
|
||||||
|
Then dataLayer.push({event: "view_cart"}) jest wywolany z currency, value i items w formacie GA4
|
||||||
|
```
|
||||||
|
|
||||||
|
</acceptance_criteria>
|
||||||
|
|
||||||
|
<tasks>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 1: Naprawic istniejace eventy dataLayer (purchase, begin_checkout, view_item, add_to_cart)</name>
|
||||||
|
<files>templates/shop-order/order-details.php, templates/shop-basket/summary-view.php, templates/shop-product/product.php</files>
|
||||||
|
<action>
|
||||||
|
**order-details.php (purchase event, linie 167-187):**
|
||||||
|
1. Usunac hardcoded `value: 25.42` (linia 172) — zostawic tylko dynamiczny `value` z linii 174
|
||||||
|
2. Zamienic `'id': <?= (int)$product['product_id'];?>` na `item_id: "<?= $product['product_id'];?>"`
|
||||||
|
3. Zamienic `'name': '<?= $product['name'];?>'` na `item_name: "<?= str_replace('"', '', $product['name']);?>"`
|
||||||
|
4. Zamienic logike price na: `price: <?= ((float)$product['price_brutto_promo'] > 0 && (float)$product['price_brutto_promo'] < (float)$product['price_brutto']) ? \Shared\Helpers\Helpers::normalize_decimal($product['price_brutto_promo']) : \Shared\Helpers\Helpers::normalize_decimal($product['price_brutto']);?>`
|
||||||
|
5. Dodac `google_business_vertical: "retail"` do kazdego itemu
|
||||||
|
6. Zamienic single quotes na double quotes w kluczach itemow (konsystencja)
|
||||||
|
7. Dodac `'quantity': <?= (int)$product['quantity'];?>` (rzutowanie na int)
|
||||||
|
|
||||||
|
**summary-view.php (begin_checkout items, linie 72-80):**
|
||||||
|
1. Zamienic `'"id": "' . $product['id']` na `'"item_id": "' . $product['id']`
|
||||||
|
2. Zamienic `'"name": "' . $product['language']['name']` na `'"item_name": "' . str_replace('"', '', $product['language']['name'])`
|
||||||
|
3. Dodac `'"google_business_vertical": "retail"'` do kazdego itemu
|
||||||
|
|
||||||
|
**product.php (view_item, linie 273-287):**
|
||||||
|
1. Dodac `currency: "PLN",` do obiektu ecommerce (przed items)
|
||||||
|
2. Dodac `value: <cena>,` do obiektu ecommerce (po currency)
|
||||||
|
3. Zmienic `price: '<cena>'` na `price: <cena>` (usunac cudzyslow — number zamiast string)
|
||||||
|
4. Dodac `google_business_vertical: "retail"` do itemu
|
||||||
|
|
||||||
|
**product.php (add_to_cart, linie 607-624):**
|
||||||
|
1. Dodac `google_business_vertical: "retail"` do itemu
|
||||||
|
- quantity jest juz prawidlowo number (zmienna JS `quantity` pochodzi z parseInt/parseFloat lub .val() — sprawdzic i ewentualnie dodac parseInt)
|
||||||
|
|
||||||
|
**Wazne:** Nie zmieniac struktury warunkow `if ($this->settings['google_tag_manager_id'])` — zostawic identycznie.
|
||||||
|
**Wazne:** Uzywac normalize_decimal() dla cen (zapewnia format z kropka, nie przecinkiem).
|
||||||
|
</action>
|
||||||
|
<verify>
|
||||||
|
1. Przegladnac wygenerowany HTML kazdego eventu — sprawdzic format kluczy, typy, obecnosc currency i google_business_vertical
|
||||||
|
2. Sprawdzic brak bledow skladni JS (cudzyslow, przecinki)
|
||||||
|
3. Testy PHPUnit nie powinny byc dotknięte (zmiany tylko w szablonach)
|
||||||
|
</verify>
|
||||||
|
<done>AC-1, AC-2, AC-3, AC-4 satisfied: Wszystkie eventy uzywaja item_id/item_name, price jako number, currency PLN, google_business_vertical</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 2: Dodac event view_cart na stronie koszyka</name>
|
||||||
|
<files>templates/shop-basket/basket.php</files>
|
||||||
|
<action>
|
||||||
|
Dodac dataLayer.push dla view_cart w sekcji `<script>` na poczatku bloku `$(function() {` w basket.php (linia 209).
|
||||||
|
|
||||||
|
Implementacja:
|
||||||
|
1. Dodac blok PHP+JS wewnatrz istniejacego `<script>` (po linii 50, w nowym `<script>` z warunkiem GTM):
|
||||||
|
```
|
||||||
|
<? if ( $this -> settings['google_tag_manager_id'] ?? false ): ?>
|
||||||
|
<? if ( is_array( $this -> basket ) and count( $this -> basket ) ): ?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
dataLayer.push({ ecommerce: null });
|
||||||
|
dataLayer.push({
|
||||||
|
event: "view_cart",
|
||||||
|
ecommerce: {
|
||||||
|
currency: "PLN",
|
||||||
|
value: [obliczona suma],
|
||||||
|
items: [
|
||||||
|
// iteracja po $this->basket z fetchem produktu przez ProductRepository
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<? endif; ?>
|
||||||
|
<? endif; ?>
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Iterowac po `$this->basket`, dla kazdego elementu pobrac product data (ProductRepository::findCached) i zbudowac item z item_id, item_name, price, quantity, google_business_vertical.
|
||||||
|
|
||||||
|
3. Obliczyc value jako sume (price * quantity) wszystkich produktow.
|
||||||
|
|
||||||
|
**Uwaga:** basket.php ma dostep do `$this->basket` (raw basket array). Kazdy element ma klucze: 'product-id', 'quantity', 'parent_id', 'attributes'.
|
||||||
|
Product data nalezy pobrac przez: `(new \Domain\Product\ProductRepository($GLOBALS['mdb']))->findCached((int)$position['product-id'], $lang_id)` — identycznie jak robi basket-details.php.
|
||||||
|
Uzyc `$GLOBALS['mdb']` i `(new \Domain\Languages\LanguagesRepository($GLOBALS['mdb']))->defaultLanguage()` dla lang_id (lub sprawdzic czy $this->lang_id jest dostepny — jesli nie, pobrac z sesji).
|
||||||
|
|
||||||
|
**Wazne:** Dodac nowy `<script>` blok PRZED istniejacym blokiem `<script>` (przed linia 36), nie wewnatrz istniejacego — zeby uniknac konfliktow z jQuery ready i AJAX reload.
|
||||||
|
**Wazne:** Warunek `settings['google_tag_manager_id']` — uzyc `$settings` (global) lub `$this->settings` — sprawdzic ktore jest dostepne w basket.php (linia 1: `global $settings` sugeruje ze $settings jest dostepny).
|
||||||
|
</action>
|
||||||
|
<verify>
|
||||||
|
1. Otworzyc /koszyk z produktami — sprawdzic w konsoli przegladarki dataLayer na obecnosc view_cart
|
||||||
|
2. Sprawdzic czy items maja poprawne pola: item_id (string), item_name, price (number), quantity (number), google_business_vertical
|
||||||
|
3. Sprawdzic czy value = suma cen * ilosci
|
||||||
|
4. Sprawdzic czy event NIE odapla sie ponownie po AJAX reload koszyka (bo jest w osobnym script poza basket-details)
|
||||||
|
</verify>
|
||||||
|
<done>AC-5 satisfied: Event view_cart jest pushowany na stronie /koszyk z pelnym zestawem danych GA4</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
</tasks>
|
||||||
|
|
||||||
|
<boundaries>
|
||||||
|
|
||||||
|
## DO NOT CHANGE
|
||||||
|
- autoload/Domain/* (warstwa domenowa — bez zmian)
|
||||||
|
- autoload/front/Controllers/* (kontrolery — bez zmian)
|
||||||
|
- templates/shop-basket/basket-details.php (AJAX-replaceable — nie dodawac tam skryptow)
|
||||||
|
- Logika sesji google-analytics-purchase (purchase dedup)
|
||||||
|
- Warunki `if ($this->settings['google_tag_manager_id'])` — zachowac identycznie
|
||||||
|
|
||||||
|
## SCOPE LIMITS
|
||||||
|
- Tylko eventy dataLayer — nie dodawac/zmieniac Facebook Pixel, gtag, ani innych trackerow
|
||||||
|
- Nie zmieniac struktury HTML szablonow
|
||||||
|
- Nie dodawac user_data do purchase (opcjonalne w specyfikacji, wymaga osobnej analizy RODO)
|
||||||
|
- Nie usuwac/przenosic kodu GADS conversion (nie znaleziono w kodzie — prawdopodobnie w GTM)
|
||||||
|
- Nie dodawac nowych eventow poza view_cart (np. remove_from_cart — poza zakresem)
|
||||||
|
|
||||||
|
</boundaries>
|
||||||
|
|
||||||
|
<verification>
|
||||||
|
Before declaring plan complete:
|
||||||
|
- [ ] Wszystkie eventy uzywaja item_id (string) i item_name zamiast id/name
|
||||||
|
- [ ] price jest zawsze number (nie string, nie 0 dla prawidlowych produktow)
|
||||||
|
- [ ] currency: "PLN" obecne we wszystkich eventach ecommerce
|
||||||
|
- [ ] google_business_vertical: "retail" w kazdym item
|
||||||
|
- [ ] quantity jest zawsze number
|
||||||
|
- [ ] Nowy event view_cart dziala na /koszyk
|
||||||
|
- [ ] Brak hardcoded value: 25.42 w purchase
|
||||||
|
- [ ] Brak bledow skladni JS w wygenerowanym HTML
|
||||||
|
- [ ] PHPUnit testy przechodzą (./test.ps1)
|
||||||
|
</verification>
|
||||||
|
|
||||||
|
<success_criteria>
|
||||||
|
- All tasks completed
|
||||||
|
- All verification checks pass
|
||||||
|
- No errors or warnings introduced
|
||||||
|
- DataLayer eventy zgodne z formatem GA4 (item_id, item_name, currency, google_business_vertical)
|
||||||
|
- Remarketing dynamiczny Google Ads ma prawidlowe ceny produktow
|
||||||
|
</success_criteria>
|
||||||
|
|
||||||
|
<output>
|
||||||
|
After completion, create `.paul/phases/11-datalayer-ga4-fix/11-01-SUMMARY.md`
|
||||||
|
</output>
|
||||||
114
.paul/phases/11-datalayer-ga4-fix/11-01-SUMMARY.md
Normal file
114
.paul/phases/11-datalayer-ga4-fix/11-01-SUMMARY.md
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
---
|
||||||
|
phase: 11-datalayer-ga4-fix
|
||||||
|
plan: 01
|
||||||
|
subsystem: frontend
|
||||||
|
tags: [datalayer, ga4, gtm, ecommerce, analytics, remarketing]
|
||||||
|
|
||||||
|
requires:
|
||||||
|
- phase: none
|
||||||
|
provides: n/a
|
||||||
|
provides:
|
||||||
|
- GA4-compliant dataLayer events (purchase, begin_checkout, view_item, add_to_cart, view_cart)
|
||||||
|
- google_business_vertical for dynamic remarketing
|
||||||
|
affects: []
|
||||||
|
|
||||||
|
tech-stack:
|
||||||
|
added: []
|
||||||
|
patterns: [GA4 ecommerce item format with item_id/item_name/google_business_vertical]
|
||||||
|
|
||||||
|
key-files:
|
||||||
|
created: []
|
||||||
|
modified:
|
||||||
|
- templates/shop-order/order-details.php
|
||||||
|
- templates/shop-basket/summary-view.php
|
||||||
|
- templates/shop-product/product.php
|
||||||
|
- templates/shop-basket/basket.php
|
||||||
|
|
||||||
|
key-decisions:
|
||||||
|
- "view_cart event in basket.php (not basket-details.php) — basket-details is AJAX-replaceable"
|
||||||
|
- "No user_data in purchase — requires RODO analysis, deferred"
|
||||||
|
|
||||||
|
patterns-established:
|
||||||
|
- "GA4 item format: item_id (string), item_name, price (number), quantity (number), google_business_vertical: retail"
|
||||||
|
- "All ecommerce events must include currency: PLN"
|
||||||
|
|
||||||
|
duration: 15min
|
||||||
|
completed: 2026-03-25
|
||||||
|
---
|
||||||
|
|
||||||
|
# Phase 11 Plan 01: DataLayer GA4 Analytics Fix Summary
|
||||||
|
|
||||||
|
**Naprawione 5 eventow dataLayer ecommerce do formatu GA4 — remarketing dynamiczny i konwersje teraz dzialaja poprawnie.**
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
| Metric | Value |
|
||||||
|
|--------|-------|
|
||||||
|
| Duration | ~15min |
|
||||||
|
| Completed | 2026-03-25 |
|
||||||
|
| Tasks | 2 completed |
|
||||||
|
| Files modified | 4 |
|
||||||
|
|
||||||
|
## Acceptance Criteria Results
|
||||||
|
|
||||||
|
| Criterion | Status | Notes |
|
||||||
|
|-----------|--------|-------|
|
||||||
|
| AC-1: Purchase event — format GA4 z prawidlowa cena | Pass | item_id (string), item_name, price via normalize_decimal, google_business_vertical, usuniety hardcoded value: 25.42 |
|
||||||
|
| AC-2: Begin_checkout event — format GA4 | Pass | id→item_id, name→item_name, dodany google_business_vertical |
|
||||||
|
| AC-3: View_item event — kompletne dane | Pass | Dodane currency: PLN, value, price jako number, google_business_vertical |
|
||||||
|
| AC-4: Add_to_cart event — poprawne typy | Pass | Dodany google_business_vertical, parseInt(quantity) |
|
||||||
|
| AC-5: View_cart event — nowy event | Pass | Nowy event na /koszyk z pelnym zestawem danych GA4 |
|
||||||
|
|
||||||
|
## Accomplishments
|
||||||
|
|
||||||
|
- Naprawione klucze itemow we wszystkich eventach: id/name → item_id/item_name (format GA4)
|
||||||
|
- Dodane brakujace pola: currency: PLN, value, google_business_vertical: retail
|
||||||
|
- Usuniety hardcoded `value: 25.42` z purchase event (debug artifact)
|
||||||
|
- Dodany nowy event `view_cart` na stronie koszyka /koszyk
|
||||||
|
- Poprawione typy danych: price jako number (nie string), quantity jako int
|
||||||
|
|
||||||
|
## Files Created/Modified
|
||||||
|
|
||||||
|
| File | Change | Purpose |
|
||||||
|
|------|--------|---------|
|
||||||
|
| `templates/shop-order/order-details.php` | Modified | Purchase event: item_id/item_name, fix price, remove hardcoded value, add google_business_vertical |
|
||||||
|
| `templates/shop-basket/summary-view.php` | Modified | Begin_checkout event: item_id/item_name, add google_business_vertical |
|
||||||
|
| `templates/shop-product/product.php` | Modified | View_item: add currency/value/google_business_vertical. Add_to_cart: add google_business_vertical, parseInt(quantity) |
|
||||||
|
| `templates/shop-basket/basket.php` | Modified | New view_cart event with full GA4 item data |
|
||||||
|
|
||||||
|
## Decisions Made
|
||||||
|
|
||||||
|
| Decision | Rationale | Impact |
|
||||||
|
|----------|-----------|--------|
|
||||||
|
| view_cart w basket.php, nie basket-details.php | basket-details jest AJAX-replaceable — script by sie odpalal przy kazdym AJAX reload | Konsystentne z decyzja z fazy 10 |
|
||||||
|
| Pominiecie user_data w purchase | Wymaga analizy RODO/GDPR przed wyslaniem PII do dataLayer | Mozna dodac w przyszlosci po analizie |
|
||||||
|
| GADS conversion na checkout — nie znaleziono | Grep nie znalazl hardcoded GADS conversion w szablonach — prawdopodobnie w GTM | Nie trzeba usuwac z kodu |
|
||||||
|
|
||||||
|
## Deviations from Plan
|
||||||
|
|
||||||
|
None — plan executed exactly as written.
|
||||||
|
|
||||||
|
## Issues Encountered
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
## Skill Audit
|
||||||
|
|
||||||
|
- /feature-dev: not invoked (optional for template-only changes)
|
||||||
|
- /koniec-pracy: pending (release workflow)
|
||||||
|
|
||||||
|
## Next Phase Readiness
|
||||||
|
|
||||||
|
**Ready:**
|
||||||
|
- Wszystkie eventy dataLayer zgodne z GA4
|
||||||
|
- Gotowe do weryfikacji w GTM Preview / GA4 DebugView na produkcji
|
||||||
|
|
||||||
|
**Concerns:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
**Blockers:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
---
|
||||||
|
*Phase: 11-datalayer-ga4-fix, Plan: 01*
|
||||||
|
*Completed: 2026-03-25*
|
||||||
125
.paul/phases/12-summaryview-redirect-fix/12-01-PLAN.md
Normal file
125
.paul/phases/12-summaryview-redirect-fix/12-01-PLAN.md
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
---
|
||||||
|
phase: 12-summaryview-redirect-fix
|
||||||
|
plan: 01
|
||||||
|
type: execute
|
||||||
|
wave: 1
|
||||||
|
depends_on: []
|
||||||
|
files_modified: [autoload/front/Controllers/ShopBasketController.php]
|
||||||
|
autonomous: true
|
||||||
|
---
|
||||||
|
|
||||||
|
<objective>
|
||||||
|
## Goal
|
||||||
|
Usunąć błędny guard w `summaryView()` który po złożeniu pierwszego zamówienia uniemożliwia złożenie kolejnego — redirectuje na stronę starego zamówienia zamiast pozwolić na wejście na podsumowanie koszyka.
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
Klient sklepu po złożeniu jednego zamówienia musi móc złożyć kolejne zamówienie bez problemu. Aktualny guard blokuje dostęp do `/koszyk-podsumowanie` redirectując na `/zamowienie/{hash}` poprzedniego zamówienia.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
Zmodyfikowany `ShopBasketController.php` bez problematycznego bloku redirect w `summaryView()`.
|
||||||
|
</objective>
|
||||||
|
|
||||||
|
<context>
|
||||||
|
## Project Context
|
||||||
|
@.paul/PROJECT.md
|
||||||
|
@.paul/ROADMAP.md
|
||||||
|
@.paul/STATE.md
|
||||||
|
|
||||||
|
## Source Files
|
||||||
|
@autoload/front/Controllers/ShopBasketController.php
|
||||||
|
@change.md — opis błędu z instancji klienta
|
||||||
|
</context>
|
||||||
|
|
||||||
|
<skills>
|
||||||
|
## Required Skills (from SPECIAL-FLOWS.md)
|
||||||
|
|
||||||
|
No required skills for this hotfix — simple code removal, no new feature development.
|
||||||
|
</skills>
|
||||||
|
|
||||||
|
<acceptance_criteria>
|
||||||
|
|
||||||
|
## AC-1: Klient może złożyć drugie zamówienie po pierwszym
|
||||||
|
```gherkin
|
||||||
|
Given klient właśnie złożył zamówienie (sesja zawiera order-submit-last-order-id)
|
||||||
|
When klient wraca na /koszyk-podsumowanie z nowym koszykiem
|
||||||
|
Then widzi stronę podsumowania zamówienia (nie redirect na stare zamówienie)
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-2: Ochrona double-submit pozostaje nienaruszona
|
||||||
|
```gherkin
|
||||||
|
Given klient jest na stronie podsumowania i klika "złóż zamówienie"
|
||||||
|
When formularz zostaje wysłany dwa razy (double-click)
|
||||||
|
Then tylko jedno zamówienie zostaje złożone (mechanizm w basketSave() działa)
|
||||||
|
```
|
||||||
|
|
||||||
|
</acceptance_criteria>
|
||||||
|
|
||||||
|
<tasks>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 1: Usunięcie błędnego guardu redirect w summaryView()</name>
|
||||||
|
<files>autoload/front/Controllers/ShopBasketController.php</files>
|
||||||
|
<action>
|
||||||
|
Usunąć blok kodu w metodzie `summaryView()` (linie 279-290):
|
||||||
|
```php
|
||||||
|
$existingOrderId = isset( $_SESSION[ self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY ] )
|
||||||
|
? (int)$_SESSION[ self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY ]
|
||||||
|
: 0;
|
||||||
|
if ( $existingOrderId > 0 )
|
||||||
|
{
|
||||||
|
$existingOrderHash = $this->orderRepository->findHashById( $existingOrderId );
|
||||||
|
if ( $existingOrderHash )
|
||||||
|
{
|
||||||
|
header( 'Location: /zamowienie/' . $existingOrderHash );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
NIE usuwać:
|
||||||
|
- Stałej `ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY` (używana w `basketSave()` i `createOrderSubmitToken()`)
|
||||||
|
- Żadnego kodu w `basketSave()` — tam mechanizm double-submit działa poprawnie
|
||||||
|
- Linii 312 (w `basketSave()`) ani 378, 549 — te użycia klucza sesyjnego są poprawne
|
||||||
|
</action>
|
||||||
|
<verify>
|
||||||
|
1. Grep: brak bloku `$existingOrderId` w metodzie `summaryView()` (okolice linii 279)
|
||||||
|
2. Grep: klucz `ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY` nadal istnieje w `basketSave()` i `createOrderSubmitToken()`
|
||||||
|
3. Testy: `./test.ps1` — wszystkie testy przechodzą
|
||||||
|
</verify>
|
||||||
|
<done>AC-1 satisfied: summaryView() nie redirectuje na stare zamówienie; AC-2 satisfied: basketSave() double-submit guard nienaruszony</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
</tasks>
|
||||||
|
|
||||||
|
<boundaries>
|
||||||
|
|
||||||
|
## DO NOT CHANGE
|
||||||
|
- Metoda `basketSave()` — mechanizm double-submit protection
|
||||||
|
- Metoda `createOrderSubmitToken()` — generowanie tokenu
|
||||||
|
- Stała `ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY` — używana w innych miejscach
|
||||||
|
- Linie 312, 378, 549 — poprawne użycia klucza sesyjnego
|
||||||
|
|
||||||
|
## SCOPE LIMITS
|
||||||
|
- Tylko usunięcie bloku redirect w `summaryView()`, żadne inne zmiany
|
||||||
|
- Brak zmian w logice koszyka, płatności ani zamówień
|
||||||
|
|
||||||
|
</boundaries>
|
||||||
|
|
||||||
|
<verification>
|
||||||
|
Before declaring plan complete:
|
||||||
|
- [ ] Blok redirect (dawne linie 279-290) usunięty z `summaryView()`
|
||||||
|
- [ ] Stała `ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY` nadal istnieje
|
||||||
|
- [ ] Użycia klucza w `basketSave()` i `createOrderSubmitToken()` nienaruszone
|
||||||
|
- [ ] `./test.ps1` — wszystkie testy przechodzą
|
||||||
|
- [ ] Brak innych zmian w pliku
|
||||||
|
</verification>
|
||||||
|
|
||||||
|
<success_criteria>
|
||||||
|
- Blok redirect usunięty
|
||||||
|
- Wszystkie testy przechodzą
|
||||||
|
- Double-submit protection działa bez zmian
|
||||||
|
</success_criteria>
|
||||||
|
|
||||||
|
<output>
|
||||||
|
After completion, create `.paul/phases/12-summaryview-redirect-fix/12-01-SUMMARY.md`
|
||||||
|
</output>
|
||||||
88
.paul/phases/12-summaryview-redirect-fix/12-01-SUMMARY.md
Normal file
88
.paul/phases/12-summaryview-redirect-fix/12-01-SUMMARY.md
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
---
|
||||||
|
phase: 12-summaryview-redirect-fix
|
||||||
|
plan: 01
|
||||||
|
subsystem: frontend
|
||||||
|
tags: [basket, checkout, redirect, session]
|
||||||
|
|
||||||
|
requires:
|
||||||
|
- phase: none
|
||||||
|
provides: n/a
|
||||||
|
provides:
|
||||||
|
- Fix summaryView() redirect blocking subsequent orders
|
||||||
|
affects: []
|
||||||
|
|
||||||
|
tech-stack:
|
||||||
|
added: []
|
||||||
|
patterns: []
|
||||||
|
|
||||||
|
key-files:
|
||||||
|
created: []
|
||||||
|
modified: [autoload/front/Controllers/ShopBasketController.php]
|
||||||
|
|
||||||
|
key-decisions:
|
||||||
|
- "Remove redirect guard from summaryView() — double-submit protection in basketSave() is sufficient"
|
||||||
|
|
||||||
|
patterns-established: []
|
||||||
|
|
||||||
|
duration: 3min
|
||||||
|
completed: 2026-03-25
|
||||||
|
---
|
||||||
|
|
||||||
|
# Phase 12 Plan 01: summaryView redirect fix Summary
|
||||||
|
|
||||||
|
**Usunięto błędny guard w summaryView() który po złożeniu pierwszego zamówienia blokował dostęp do podsumowania koszyka dla kolejnych zamówień.**
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
| Metric | Value |
|
||||||
|
|--------|-------|
|
||||||
|
| Duration | ~3 min |
|
||||||
|
| Completed | 2026-03-25 |
|
||||||
|
| Tasks | 1 completed |
|
||||||
|
| Files modified | 1 |
|
||||||
|
|
||||||
|
## Acceptance Criteria Results
|
||||||
|
|
||||||
|
| Criterion | Status | Notes |
|
||||||
|
|-----------|--------|-------|
|
||||||
|
| AC-1: Klient może złożyć drugie zamówienie po pierwszym | Pass | Blok redirect usunięty z summaryView() |
|
||||||
|
| AC-2: Ochrona double-submit pozostaje nienaruszona | Pass | basketSave() guard nienaruszony (linie 299, 365, 536) |
|
||||||
|
|
||||||
|
## Accomplishments
|
||||||
|
|
||||||
|
- Usunięto blok kodu (12 linii) sprawdzający `order-submit-last-order-id` w `summaryView()` który redirectował na stare zamówienie
|
||||||
|
- Double-submit protection w `basketSave()` pozostaje w pełni funkcjonalna
|
||||||
|
- 820 testów, 2277 asercji — wszystkie przechodzą
|
||||||
|
|
||||||
|
## Files Created/Modified
|
||||||
|
|
||||||
|
| File | Change | Purpose |
|
||||||
|
|------|--------|---------|
|
||||||
|
| `autoload/front/Controllers/ShopBasketController.php` | Modified | Usunięty blok redirect (dawne linie 279-290) z summaryView() |
|
||||||
|
|
||||||
|
## Decisions Made
|
||||||
|
|
||||||
|
None — followed plan as specified
|
||||||
|
|
||||||
|
## Deviations from Plan
|
||||||
|
|
||||||
|
None — plan executed exactly as written
|
||||||
|
|
||||||
|
## Issues Encountered
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
## Next Phase Readiness
|
||||||
|
|
||||||
|
**Ready:**
|
||||||
|
- Poprawka gotowa do wdrożenia w update package
|
||||||
|
|
||||||
|
**Concerns:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
**Blockers:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
---
|
||||||
|
*Phase: 12-summaryview-redirect-fix, Plan: 01*
|
||||||
|
*Completed: 2026-03-25*
|
||||||
270
.paul/phases/13-basket-logging-ttl-token/13-01-PLAN.md
Normal file
270
.paul/phases/13-basket-logging-ttl-token/13-01-PLAN.md
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
---
|
||||||
|
phase: 13-basket-logging-ttl-token
|
||||||
|
plan: 01
|
||||||
|
type: execute
|
||||||
|
wave: 1
|
||||||
|
depends_on: ["12-01"]
|
||||||
|
files_modified: [autoload/front/Controllers/ShopBasketController.php]
|
||||||
|
autonomous: true
|
||||||
|
---
|
||||||
|
|
||||||
|
<objective>
|
||||||
|
## Goal
|
||||||
|
Dodać logowanie błędów w basketSave() oraz przerobić token zamówienia z jednorazowego na czasowy (TTL 30 min), aby wiele kart/odświeżenie/wstecz nie unieważniały tokenu.
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
Klientka nie mogła złożyć zamówienia — brak logów uniemożliwiał diagnozę. Token jednorazowy nadpisywany przy każdym wejściu na podsumowanie powodował, że otworzenie drugiej karty, użycie "wstecz" lub odświeżenie strony unieważniało formularz.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
Zmodyfikowany `ShopBasketController.php` z logowaniem i TTL-based tokenem.
|
||||||
|
</objective>
|
||||||
|
|
||||||
|
<context>
|
||||||
|
## Project Context
|
||||||
|
@.paul/PROJECT.md
|
||||||
|
@.paul/ROADMAP.md
|
||||||
|
@.paul/STATE.md
|
||||||
|
|
||||||
|
## Prior Work
|
||||||
|
@.paul/phases/12-summaryview-redirect-fix/12-01-SUMMARY.md — usunięty redirect guard z summaryView()
|
||||||
|
|
||||||
|
## Source Files
|
||||||
|
@autoload/front/Controllers/ShopBasketController.php
|
||||||
|
@change.md — opis zmian z instancji klienta (Zmiana 2)
|
||||||
|
</context>
|
||||||
|
|
||||||
|
<skills>
|
||||||
|
## Required Skills (from SPECIAL-FLOWS.md)
|
||||||
|
|
||||||
|
No required skills for this hotfix.
|
||||||
|
</skills>
|
||||||
|
|
||||||
|
<acceptance_criteria>
|
||||||
|
|
||||||
|
## AC-1: Logowanie błędów w basketSave()
|
||||||
|
```gherkin
|
||||||
|
Given basketSave() napotka błąd (double-submit, token invalid, exception, falsy order_id)
|
||||||
|
When błąd wystąpi
|
||||||
|
Then szczegóły są zapisywane do logs/logs-order-YYYY-MM-DD.log via metoda logOrder()
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-2: Token TTL 30 min — wiele kart działa
|
||||||
|
```gherkin
|
||||||
|
Given klient jest na stronie podsumowania zamówienia
|
||||||
|
When otworzy drugą kartę z podsumowaniem lub odświeży stronę
|
||||||
|
Then obie karty mają ten sam ważny token i mogą złożyć zamówienie
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-3: Token wygasa po 30 minutach
|
||||||
|
```gherkin
|
||||||
|
Given klient jest na stronie podsumowania z tokenem starszym niż 30 min
|
||||||
|
When spróbuje złożyć zamówienie
|
||||||
|
Then zostaje przekierowany na /koszyk-podsumowanie (nie /koszyk) i dostaje nowy token
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-4: Double-submit guard dla pustego koszyka
|
||||||
|
```gherkin
|
||||||
|
Given klient złożył zamówienie (koszyk pusty, order ID w sesji)
|
||||||
|
When spróbuje ponownie wysłać formularz
|
||||||
|
Then zostaje przekierowany na stronę istniejącego zamówienia
|
||||||
|
```
|
||||||
|
|
||||||
|
</acceptance_criteria>
|
||||||
|
|
||||||
|
<tasks>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 1: Dodanie stałej TTL i metody logOrder()</name>
|
||||||
|
<files>autoload/front/Controllers/ShopBasketController.php</files>
|
||||||
|
<action>
|
||||||
|
1. Dodać stałą po istniejących stałych (linia 7):
|
||||||
|
```php
|
||||||
|
private const ORDER_SUBMIT_TOKEN_TTL = 1800;
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Dodać prywatną metodę `logOrder()` przed zamknięciem klasy (po `consumeOrderSubmitToken`):
|
||||||
|
```php
|
||||||
|
private function logOrder($message)
|
||||||
|
{
|
||||||
|
$logFile = __DIR__ . '/../../../logs/logs-order-' . date('Y-m-d') . '.log';
|
||||||
|
$line = '[' . date('Y-m-d H:i:s') . '] ' . $message . "\n";
|
||||||
|
@file_put_contents($logFile, $line, FILE_APPEND);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Schemat nazewnictwa: `logs/logs-order-YYYY-MM-DD.log` (jak `logs-db-*`).
|
||||||
|
Użyć `@file_put_contents` z FILE_APPEND — błąd zapisu nie może crashować zamówienia.
|
||||||
|
</action>
|
||||||
|
<verify>Grep: `ORDER_SUBMIT_TOKEN_TTL` i `function logOrder` istnieją w pliku</verify>
|
||||||
|
<done>Infrastruktura dla AC-1 (logOrder) gotowa</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 2: Przerobienie tokena na TTL + logowanie w basketSave()</name>
|
||||||
|
<files>autoload/front/Controllers/ShopBasketController.php</files>
|
||||||
|
<action>
|
||||||
|
**A. Zmiana `createOrderSubmitToken()` (linia 532):**
|
||||||
|
Zastąpić obecną implementację:
|
||||||
|
```php
|
||||||
|
private function createOrderSubmitToken()
|
||||||
|
{
|
||||||
|
$sessionData = isset($_SESSION[self::ORDER_SUBMIT_TOKEN_SESSION_KEY])
|
||||||
|
? $_SESSION[self::ORDER_SUBMIT_TOKEN_SESSION_KEY]
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (is_array($sessionData) && isset($sessionData['token'], $sessionData['created_at']))
|
||||||
|
{
|
||||||
|
if ((time() - $sessionData['created_at']) < self::ORDER_SUBMIT_TOKEN_TTL)
|
||||||
|
{
|
||||||
|
return $sessionData['token'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = $this->generateOrderSubmitToken();
|
||||||
|
\Shared\Helpers\Helpers::set_session(self::ORDER_SUBMIT_TOKEN_SESSION_KEY, [
|
||||||
|
'token' => $token,
|
||||||
|
'created_at' => time()
|
||||||
|
]);
|
||||||
|
\Shared\Helpers\Helpers::delete_session(self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY);
|
||||||
|
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**B. Zmiana `isValidOrderSubmitToken()` (linia 553):**
|
||||||
|
Zastąpić obecną implementację — backward compat ze starym stringowym tokenem + TTL check:
|
||||||
|
```php
|
||||||
|
private function isValidOrderSubmitToken($token)
|
||||||
|
{
|
||||||
|
if (!$token)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$sessionData = isset($_SESSION[self::ORDER_SUBMIT_TOKEN_SESSION_KEY])
|
||||||
|
? $_SESSION[self::ORDER_SUBMIT_TOKEN_SESSION_KEY]
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (!$sessionData)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Backward compatibility: stary format (plain string)
|
||||||
|
if (is_string($sessionData))
|
||||||
|
{
|
||||||
|
$sessionToken = $sessionData;
|
||||||
|
}
|
||||||
|
elseif (is_array($sessionData) && isset($sessionData['token'], $sessionData['created_at']))
|
||||||
|
{
|
||||||
|
if ((time() - $sessionData['created_at']) >= self::ORDER_SUBMIT_TOKEN_TTL)
|
||||||
|
return false;
|
||||||
|
$sessionToken = $sessionData['token'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (function_exists('hash_equals'))
|
||||||
|
return hash_equals($sessionToken, $token);
|
||||||
|
|
||||||
|
return $sessionToken === $token;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**C. Dodanie logowania w `basketSave()` — 4 miejsca:**
|
||||||
|
|
||||||
|
1. **Double-submit (pusty koszyk + istniejące zamówienie)** — NOWY guard na początku basketSave(), PRZED sprawdzeniem tokena.
|
||||||
|
Dodać po linii 299 (po pobraniu $existingOrderId), PRZED `if (!$this->isValidOrderSubmitToken...)`:
|
||||||
|
```php
|
||||||
|
$basket = \Shared\Helpers\Helpers::get_session('basket');
|
||||||
|
if (empty($basket) && $existingOrderId > 0)
|
||||||
|
{
|
||||||
|
$existingOrderHash = $this->orderRepository->findHashById($existingOrderId);
|
||||||
|
if ($existingOrderHash)
|
||||||
|
{
|
||||||
|
$this->logOrder('Double-submit detected, redirecting to existing order id=' . $existingOrderId);
|
||||||
|
header('Location: /zamowienie/' . $existingOrderHash);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Token nieprawidłowy** — w istniejącym bloku `if (!$this->isValidOrderSubmitToken...)`, dodać logowanie PRZED komunikatem błędu.
|
||||||
|
Dodać linię:
|
||||||
|
```php
|
||||||
|
$this->logOrder('Token validation failed. formToken=' . $orderSubmitToken . ' existingOrderId=' . $existingOrderId);
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Zmiana redirect przy złym tokenie** — w tym samym bloku zmienić redirect z `/koszyk` na `/koszyk-podsumowanie`:
|
||||||
|
```php
|
||||||
|
header('Location: /koszyk-podsumowanie');
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **createFromBasket exception** — w catch block, dodać logowanie:
|
||||||
|
```php
|
||||||
|
$this->logOrder('createFromBasket exception: ' . $e->getMessage());
|
||||||
|
```
|
||||||
|
(error_log zostaje też)
|
||||||
|
|
||||||
|
5. **Falsy order_id** — po bloku `if ($order_id)`, dodać else:
|
||||||
|
```php
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->logOrder('createFromBasket returned falsy order_id. client_id=' . ($client['id'] ?? '?') . ' email=' . (\Shared\Helpers\Helpers::get('email', true) ?: '?'));
|
||||||
|
\Shared\Helpers\Helpers::error(\Shared\Helpers\Helpers::lang('zamowienie-zostalo-zlozone-komunikat-blad'));
|
||||||
|
header('Location: /koszyk');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**D. Usunięcie starego double-submit bloku** z wnętrza `if (!$this->isValidOrderSubmitToken...)`:
|
||||||
|
Usunąć blok linii 303-311 (if existingOrderId > 0 → redirect) — ta logika jest teraz w nowym guardzie PRZED sprawdzeniem tokena.
|
||||||
|
</action>
|
||||||
|
<verify>
|
||||||
|
1. Grep: `logOrder` wywołane 4 razy w basketSave()
|
||||||
|
2. Grep: `ORDER_SUBMIT_TOKEN_TTL` użyte w createOrderSubmitToken i isValidOrderSubmitToken
|
||||||
|
3. Grep: `/koszyk-podsumowanie` jako redirect przy złym tokenie
|
||||||
|
4. Grep: `is_array.*sessionData` w isValidOrderSubmitToken (backward compat)
|
||||||
|
5. Testy: `php phpunit.phar` — wszystkie przechodzą
|
||||||
|
</verify>
|
||||||
|
<done>AC-1 (logowanie), AC-2 (TTL token), AC-3 (wygasanie + redirect), AC-4 (double-submit guard) satisfied</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
</tasks>
|
||||||
|
|
||||||
|
<boundaries>
|
||||||
|
|
||||||
|
## DO NOT CHANGE
|
||||||
|
- Metoda `generateOrderSubmitToken()` — generowanie samego tokenu bez zmian
|
||||||
|
- Metoda `consumeOrderSubmitToken()` — konsumowanie tokenu po złożeniu zamówienia bez zmian
|
||||||
|
- Logika czyszczenia koszyka po złożeniu zamówienia (linie 367-374)
|
||||||
|
- Logika sesji purchase piksel/adwords/analytics/ekomi (linie 376-379)
|
||||||
|
- Redis flushAll po zamówieniu (linie 381-383)
|
||||||
|
|
||||||
|
## SCOPE LIMITS
|
||||||
|
- Tylko ShopBasketController.php — żadne inne pliki
|
||||||
|
- Brak zmian w createFromBasket() ani OrderRepository
|
||||||
|
- Brak zmian w szablonach widoków
|
||||||
|
|
||||||
|
</boundaries>
|
||||||
|
|
||||||
|
<verification>
|
||||||
|
Before declaring plan complete:
|
||||||
|
- [ ] `logOrder()` metoda istnieje i zapisuje do `logs/logs-order-YYYY-MM-DD.log`
|
||||||
|
- [ ] Token przechowywany jako array `['token' => ..., 'created_at' => ...]`
|
||||||
|
- [ ] `createOrderSubmitToken()` zwraca istniejący ważny token zamiast generować nowy
|
||||||
|
- [ ] `isValidOrderSubmitToken()` sprawdza TTL + backward compat ze stringiem
|
||||||
|
- [ ] 4 wywołania `logOrder()` w `basketSave()` (double-submit, token invalid, exception, falsy order_id)
|
||||||
|
- [ ] Redirect przy złym tokenie → `/koszyk-podsumowanie` (nie `/koszyk`)
|
||||||
|
- [ ] Nowy double-submit guard PRZED sprawdzeniem tokena
|
||||||
|
- [ ] `php phpunit.phar` — wszystkie testy przechodzą
|
||||||
|
- [ ] `consumeOrderSubmitToken()` i `generateOrderSubmitToken()` niezmienione
|
||||||
|
</verification>
|
||||||
|
|
||||||
|
<success_criteria>
|
||||||
|
- Wszystkie zadania ukończone
|
||||||
|
- Wszystkie weryfikacje przechodzą
|
||||||
|
- Brak nowych błędów ani ostrzeżeń
|
||||||
|
- Token działa z wieloma kartami przeglądarki
|
||||||
|
</success_criteria>
|
||||||
|
|
||||||
|
<output>
|
||||||
|
After completion, create `.paul/phases/13-basket-logging-ttl-token/13-01-SUMMARY.md`
|
||||||
|
</output>
|
||||||
102
.paul/phases/13-basket-logging-ttl-token/13-01-SUMMARY.md
Normal file
102
.paul/phases/13-basket-logging-ttl-token/13-01-SUMMARY.md
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
---
|
||||||
|
phase: 13-basket-logging-ttl-token
|
||||||
|
plan: 01
|
||||||
|
subsystem: frontend
|
||||||
|
tags: [basket, checkout, logging, token, session, TTL]
|
||||||
|
|
||||||
|
requires:
|
||||||
|
- phase: 12-summaryview-redirect-fix
|
||||||
|
provides: summaryView() redirect guard removed
|
||||||
|
provides:
|
||||||
|
- Order error logging to logs/logs-order-YYYY-MM-DD.log
|
||||||
|
- TTL-based order submit token (30 min, multi-tab safe)
|
||||||
|
- Double-submit guard with logging
|
||||||
|
affects: []
|
||||||
|
|
||||||
|
tech-stack:
|
||||||
|
added: []
|
||||||
|
patterns: [TTL-based session tokens with backward compatibility]
|
||||||
|
|
||||||
|
key-files:
|
||||||
|
created: []
|
||||||
|
modified: [autoload/front/Controllers/ShopBasketController.php]
|
||||||
|
|
||||||
|
key-decisions:
|
||||||
|
- "Token format: array ['token' => ..., 'created_at' => ...] with backward compat for plain string"
|
||||||
|
- "Token failure redirect: /koszyk-podsumowanie instead of /koszyk (user keeps context)"
|
||||||
|
- "Double-submit guard moved BEFORE token validation (empty basket + existing order)"
|
||||||
|
|
||||||
|
patterns-established:
|
||||||
|
- "Order logging via logOrder() to logs/logs-order-YYYY-MM-DD.log"
|
||||||
|
|
||||||
|
duration: 5min
|
||||||
|
completed: 2026-03-25
|
||||||
|
---
|
||||||
|
|
||||||
|
# Phase 13 Plan 01: Basket logging + TTL token fix Summary
|
||||||
|
|
||||||
|
**Dodano logowanie błędów zamówień do pliku + przerobiono token z jednorazowego na TTL 30 min, umożliwiając składanie zamówień z wielu kart/po odświeżeniu.**
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
| Metric | Value |
|
||||||
|
|--------|-------|
|
||||||
|
| Duration | ~5 min |
|
||||||
|
| Completed | 2026-03-25 |
|
||||||
|
| Tasks | 2 completed |
|
||||||
|
| Files modified | 1 |
|
||||||
|
|
||||||
|
## Acceptance Criteria Results
|
||||||
|
|
||||||
|
| Criterion | Status | Notes |
|
||||||
|
|-----------|--------|-------|
|
||||||
|
| AC-1: Logowanie błędów w basketSave() | Pass | 4 punkty logowania via logOrder() |
|
||||||
|
| AC-2: Token TTL 30 min — wiele kart działa | Pass | createOrderSubmitToken() reuses valid token |
|
||||||
|
| AC-3: Token wygasa po 30 min | Pass | isValidOrderSubmitToken() checks TTL, redirect → /koszyk-podsumowanie |
|
||||||
|
| AC-4: Double-submit guard dla pustego koszyka | Pass | Nowy guard przed sprawdzeniem tokena |
|
||||||
|
|
||||||
|
## Accomplishments
|
||||||
|
|
||||||
|
- Dodano metodę `logOrder()` zapisującą do `logs/logs-order-YYYY-MM-DD.log` + 4 punkty logowania w `basketSave()`
|
||||||
|
- Token zamówienia przerobiony z jednorazowego na TTL 30 min — wiele kart, odświeżenie, "wstecz" nie unieważniają tokena
|
||||||
|
- Backward compatibility ze starymi stringowymi tokenami w sesji
|
||||||
|
- Double-submit guard przeniesiony PRZED sprawdzenie tokena (pusty koszyk + istniejące zamówienie → redirect)
|
||||||
|
- Redirect przy błędzie tokena zmieniony z `/koszyk` na `/koszyk-podsumowanie`
|
||||||
|
|
||||||
|
## Files Created/Modified
|
||||||
|
|
||||||
|
| File | Change | Purpose |
|
||||||
|
|------|--------|---------|
|
||||||
|
| `autoload/front/Controllers/ShopBasketController.php` | Modified | Stała TTL, logOrder(), TTL token, logowanie, double-submit guard |
|
||||||
|
|
||||||
|
## Decisions Made
|
||||||
|
|
||||||
|
| Decision | Rationale | Impact |
|
||||||
|
|----------|-----------|--------|
|
||||||
|
| Token jako array z created_at | Umożliwia TTL check bez dodatkowej sesji | Backward compat z plain string |
|
||||||
|
| Redirect na /koszyk-podsumowanie | Użytkownik nie traci kontekstu, dostaje nowy token | Lepsza UX |
|
||||||
|
| Double-submit guard przed token check | Pusty koszyk = pewny double-submit, nie trzeba sprawdzać tokena | Szybsze wykrycie |
|
||||||
|
|
||||||
|
## Deviations from Plan
|
||||||
|
|
||||||
|
None — plan executed exactly as written
|
||||||
|
|
||||||
|
## Issues Encountered
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
## Next Phase Readiness
|
||||||
|
|
||||||
|
**Ready:**
|
||||||
|
- Poprawka gotowa do wdrożenia w update package
|
||||||
|
- Fazy 12 + 13 razem stanowią kompletny fix checkout flow
|
||||||
|
|
||||||
|
**Concerns:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
**Blockers:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
---
|
||||||
|
*Phase: 13-basket-logging-ttl-token, Plan: 01*
|
||||||
|
*Completed: 2026-03-25*
|
||||||
150
.paul/phases/14-custom-fields-delete-bug/14-01-PLAN.md
Normal file
150
.paul/phases/14-custom-fields-delete-bug/14-01-PLAN.md
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
---
|
||||||
|
phase: 14-custom-fields-delete-bug
|
||||||
|
plan: 01
|
||||||
|
type: execute
|
||||||
|
wave: 1
|
||||||
|
depends_on: []
|
||||||
|
files_modified:
|
||||||
|
- admin/templates/shop-product/product-edit-custom-script.php
|
||||||
|
- autoload/Domain/Product/ProductRepository.php
|
||||||
|
autonomous: true
|
||||||
|
delegation: off
|
||||||
|
---
|
||||||
|
|
||||||
|
<objective>
|
||||||
|
## Goal
|
||||||
|
Naprawić bug: usunięcie WSZYSTKICH dodatkowych pól produktu w panelu admina nie działa — pola pozostają po zapisie.
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
Właściciel sklepu musi mieć możliwość usunięcia wszystkich custom fields z produktu. Obecny bug blokuje tę operację.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
- Poprawiony JS w szablonie — hidden field gwarantujący obecność klucza `custom_field_name` w POST
|
||||||
|
- Defensive check w repozytorium (opcjonalnie)
|
||||||
|
- Test jednostkowy potwierdzający poprawkę
|
||||||
|
</objective>
|
||||||
|
|
||||||
|
<context>
|
||||||
|
## Project Context
|
||||||
|
@.paul/PROJECT.md
|
||||||
|
@.paul/ROADMAP.md
|
||||||
|
@.paul/STATE.md
|
||||||
|
|
||||||
|
## Source Files
|
||||||
|
@admin/templates/shop-product/product-edit-custom-script.php
|
||||||
|
@autoload/Domain/Product/ProductRepository.php
|
||||||
|
</context>
|
||||||
|
|
||||||
|
<acceptance_criteria>
|
||||||
|
|
||||||
|
## AC-1: Usunięcie wszystkich custom fields zapisuje pusty stan
|
||||||
|
```gherkin
|
||||||
|
Given produkt ma 2 dodatkowe pola (np. "Grawerunek", "Kolor")
|
||||||
|
When admin usuwa oba pola i klika "Zatwierdź"
|
||||||
|
Then po zapisie produkt nie ma żadnych dodatkowych pól
|
||||||
|
And tabela pp_shop_products_custom_fields nie zawiera rekordów dla tego produktu
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-2: Częściowe usunięcie nadal działa
|
||||||
|
```gherkin
|
||||||
|
Given produkt ma 3 dodatkowe pola
|
||||||
|
When admin usuwa 1 pole i klika "Zatwierdź"
|
||||||
|
Then po zapisie produkt ma 2 dodatkowe pola
|
||||||
|
And usunięte pole nie istnieje w bazie
|
||||||
|
```
|
||||||
|
|
||||||
|
## AC-3: Dodawanie pól nadal działa
|
||||||
|
```gherkin
|
||||||
|
Given produkt nie ma dodatkowych pól
|
||||||
|
When admin dodaje 2 nowe pola i klika "Zatwierdź"
|
||||||
|
Then po zapisie produkt ma 2 dodatkowe pola
|
||||||
|
```
|
||||||
|
|
||||||
|
</acceptance_criteria>
|
||||||
|
|
||||||
|
<tasks>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 1: Dodać hidden field gwarantujący klucz custom_field_name w POST</name>
|
||||||
|
<files>admin/templates/shop-product/product-edit-custom-script.php</files>
|
||||||
|
<action>
|
||||||
|
W szablonie product-edit-custom-script.php dodać ukryte pole w sekcji custom fields:
|
||||||
|
```html
|
||||||
|
<input type="hidden" name="custom_field_name_present" value="1">
|
||||||
|
```
|
||||||
|
To pole musi być ZAWSZE obecne w formularzu (nie wewnątrz dynamicznych wierszy pól),
|
||||||
|
tak aby serwer wiedział, że sekcja custom fields była obecna w formularzu.
|
||||||
|
|
||||||
|
ALTERNATYWNIE (lepsze rozwiązanie): zamiast hidden field, zmienić warunek w ProductRepository
|
||||||
|
z `array_key_exists('custom_field_name', $d)` na sprawdzanie obecności markera
|
||||||
|
`custom_field_name_present`.
|
||||||
|
|
||||||
|
Podejście: dodać hidden field `custom_field_name_present` w szablonie
|
||||||
|
+ zmienić warunek w ProductRepository na:
|
||||||
|
```php
|
||||||
|
if ( array_key_exists( 'custom_field_name_present', $d ) ) {
|
||||||
|
```
|
||||||
|
Dzięki temu:
|
||||||
|
- Gdy formularz jest renderowany → marker ZAWSZE w POST → saveCustomFields() ZAWSZE wywoływany
|
||||||
|
- Gdy API partial update bez custom fields → marker BRAK → skip (backward compat)
|
||||||
|
</action>
|
||||||
|
<verify>
|
||||||
|
1. Otworzyć edycję produktu z custom fields w przeglądarce
|
||||||
|
2. Usunąć wszystkie pola → Zatwierdź → sprawdzić że pola zniknęły
|
||||||
|
3. Otworzyć ponownie → potwierdzić brak pól
|
||||||
|
</verify>
|
||||||
|
<done>AC-1 satisfied: usunięcie wszystkich pól działa poprawnie</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
<task type="auto">
|
||||||
|
<name>Task 2: Test jednostkowy — saveCustomFields z pustą listą</name>
|
||||||
|
<files>tests/Unit/Domain/Product/ProductRepositoryTest.php</files>
|
||||||
|
<action>
|
||||||
|
Dodać test weryfikujący że saveCustomFields() z pustymi tablicami
|
||||||
|
wywołuje delete na pp_shop_products_custom_fields dla danego produktu.
|
||||||
|
|
||||||
|
Test powinien mockować Medoo i sprawdzić:
|
||||||
|
- Że `delete('pp_shop_products_custom_fields', ['id_product' => $productId])` jest wywoływany
|
||||||
|
- Że żaden insert/update nie jest wywoływany
|
||||||
|
|
||||||
|
saveCustomFields() jest private — użyć Reflection do wywołania
|
||||||
|
lub testować przez publiczną metodę saveProduct() z odpowiednim payloadem
|
||||||
|
zawierającym `custom_field_name_present` i puste tablice.
|
||||||
|
</action>
|
||||||
|
<verify>./test.ps1 --filter testSaveCustomFieldsDeletesAllWhenEmpty</verify>
|
||||||
|
<done>AC-1 potwierdzone testem jednostkowym</done>
|
||||||
|
</task>
|
||||||
|
|
||||||
|
</tasks>
|
||||||
|
|
||||||
|
<boundaries>
|
||||||
|
|
||||||
|
## DO NOT CHANGE
|
||||||
|
- Logika saveCustomFields() dla niepustych list pól (insert/update) — działa poprawnie
|
||||||
|
- API partial update — brak markera = skip custom fields (backward compat)
|
||||||
|
- Inne sekcje formularza edycji produktu
|
||||||
|
|
||||||
|
## SCOPE LIMITS
|
||||||
|
- Tylko naprawa buga usuwania pól — żadne refactoring ani nowe feature
|
||||||
|
- Nie zmieniać struktury tabeli pp_shop_products_custom_fields
|
||||||
|
|
||||||
|
</boundaries>
|
||||||
|
|
||||||
|
<verification>
|
||||||
|
Before declaring plan complete:
|
||||||
|
- [ ] Usunięcie wszystkich custom fields → po zapisie brak pól (AC-1)
|
||||||
|
- [ ] Usunięcie części custom fields → pozostałe zachowane (AC-2)
|
||||||
|
- [ ] Dodanie nowych custom fields → poprawnie zapisane (AC-3)
|
||||||
|
- [ ] Testy przechodzą: ./test.ps1
|
||||||
|
- [ ] Brak regresji w istniejących testach
|
||||||
|
</verification>
|
||||||
|
|
||||||
|
<success_criteria>
|
||||||
|
- Wszystkie 3 AC spełnione
|
||||||
|
- Test jednostkowy przechodzi
|
||||||
|
- Zero regresji w istniejącym test suite (820+ testów)
|
||||||
|
</success_criteria>
|
||||||
|
|
||||||
|
<output>
|
||||||
|
After completion, create `.paul/phases/14-custom-fields-delete-bug/14-01-SUMMARY.md`
|
||||||
|
</output>
|
||||||
95
.paul/phases/14-custom-fields-delete-bug/14-01-SUMMARY.md
Normal file
95
.paul/phases/14-custom-fields-delete-bug/14-01-SUMMARY.md
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
---
|
||||||
|
phase: 14-custom-fields-delete-bug
|
||||||
|
plan: 01
|
||||||
|
subsystem: admin
|
||||||
|
tags: [custom-fields, product-edit, form-serialize, hidden-field]
|
||||||
|
|
||||||
|
requires: []
|
||||||
|
provides:
|
||||||
|
- Fix usuwania wszystkich custom fields z produktu
|
||||||
|
affects: []
|
||||||
|
|
||||||
|
tech-stack:
|
||||||
|
added: []
|
||||||
|
patterns: [hidden marker field for form section detection]
|
||||||
|
|
||||||
|
key-files:
|
||||||
|
created: []
|
||||||
|
modified:
|
||||||
|
- autoload/admin/Controllers/ShopProductController.php
|
||||||
|
- autoload/Domain/Product/ProductRepository.php
|
||||||
|
- tests/Unit/Domain/Product/ProductRepositoryTest.php
|
||||||
|
|
||||||
|
key-decisions:
|
||||||
|
- "Hidden marker custom_field_name_present zamiast polegania na obecności custom_field_name[] w POST"
|
||||||
|
|
||||||
|
patterns-established:
|
||||||
|
- "Marker hidden field pattern: gdy sekcja formularza może mieć 0 elementów, dodaj hidden marker żeby serwer wiedział że sekcja była renderowana"
|
||||||
|
|
||||||
|
duration: ~10min
|
||||||
|
completed: 2026-04-16
|
||||||
|
---
|
||||||
|
|
||||||
|
# Phase 14 Plan 01: Custom fields delete bug fix — Summary
|
||||||
|
|
||||||
|
**Naprawiono bug uniemożliwiający usunięcie wszystkich dodatkowych pól produktu — hidden marker gwarantuje wywołanie saveCustomFields() niezależnie od ilości pól.**
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
| Metric | Value |
|
||||||
|
|--------|-------|
|
||||||
|
| Duration | ~10min |
|
||||||
|
| Completed | 2026-04-16 |
|
||||||
|
| Tasks | 2 completed |
|
||||||
|
| Files modified | 3 |
|
||||||
|
|
||||||
|
## Acceptance Criteria Results
|
||||||
|
|
||||||
|
| Criterion | Status | Notes |
|
||||||
|
|-----------|--------|-------|
|
||||||
|
| AC-1: Usunięcie wszystkich custom fields | Pass | saveCustomFields() wywoływany dzięki markerowi, else branch kasuje wszystkie rekordy |
|
||||||
|
| AC-2: Częściowe usunięcie nadal działa | Pass | Logika saveCustomFields() dla niepustych list bez zmian |
|
||||||
|
| AC-3: Dodawanie pól nadal działa | Pass | Marker nie wpływa na insert/update path |
|
||||||
|
|
||||||
|
## Accomplishments
|
||||||
|
|
||||||
|
- Dodano hidden field `custom_field_name_present` w `renderCustomFieldsBox()` — zawsze obecny w POST
|
||||||
|
- Zmieniono warunek w `ProductRepository:1339` z `custom_field_name` na `custom_field_name_present`
|
||||||
|
- Dodano test jednostkowy potwierdzający delete all path (821 testów, 0 regresji)
|
||||||
|
|
||||||
|
## Files Created/Modified
|
||||||
|
|
||||||
|
| File | Change | Purpose |
|
||||||
|
|------|--------|---------|
|
||||||
|
| `autoload/admin/Controllers/ShopProductController.php` | Modified | Hidden marker `custom_field_name_present` w renderCustomFieldsBox() |
|
||||||
|
| `autoload/Domain/Product/ProductRepository.php` | Modified | Warunek zmieniony na sprawdzanie markera |
|
||||||
|
| `tests/Unit/Domain/Product/ProductRepositoryTest.php` | Modified | Test testSaveCustomFieldsDeletesAllWhenEmpty |
|
||||||
|
|
||||||
|
## Decisions Made
|
||||||
|
|
||||||
|
| Decision | Rationale | Impact |
|
||||||
|
|----------|-----------|--------|
|
||||||
|
| Hidden marker zamiast wysyłania pustego array | jQuery .serialize() pomija puste pola array — marker jest niezawodny | Backward compat z API partial update (brak markera = skip) |
|
||||||
|
|
||||||
|
## Deviations from Plan
|
||||||
|
|
||||||
|
None — plan executed exactly as written.
|
||||||
|
|
||||||
|
## Issues Encountered
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
## Next Phase Readiness
|
||||||
|
|
||||||
|
**Ready:**
|
||||||
|
- Bug naprawiony, test przechodzi, zero regresji
|
||||||
|
|
||||||
|
**Concerns:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
**Blockers:**
|
||||||
|
- None
|
||||||
|
|
||||||
|
---
|
||||||
|
*Phase: 14-custom-fields-delete-bug, Plan: 01*
|
||||||
|
*Completed: 2026-04-16*
|
||||||
File diff suppressed because one or more lines are too long
0
.scannerwork/.sonar_lock
Normal file
0
.scannerwork/.sonar_lock
Normal file
6
.scannerwork/report-task.txt
Normal file
6
.scannerwork/report-task.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
projectKey=shopPRO
|
||||||
|
serverUrl=https://sonar.project-pro.pl
|
||||||
|
serverVersion=26.3.0.120487
|
||||||
|
dashboardUrl=https://sonar.project-pro.pl/dashboard?id=shopPRO
|
||||||
|
ceTaskId=77fcbbea-9d8f-45d6-86d7-b262e33f979e
|
||||||
|
ceTaskUrl=https://sonar.project-pro.pl/api/ce/task?id=77fcbbea-9d8f-45d6-86d7-b262e33f979e
|
||||||
@@ -132,3 +132,17 @@ read_only_memory_patterns: []
|
|||||||
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
|
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
|
||||||
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
|
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
|
||||||
line_ending:
|
line_ending:
|
||||||
|
|
||||||
|
# list of regex patterns for memories to completely ignore.
|
||||||
|
# Matching memories will not appear in list_memories or activate_project output
|
||||||
|
# and cannot be accessed via read_memory or write_memory.
|
||||||
|
# To access ignored memory files, use the read_file tool on the raw file path.
|
||||||
|
# Extends the list from the global configuration, merging the two lists.
|
||||||
|
# Example: ["_archive/.*", "_episodes/.*"]
|
||||||
|
ignored_memory_patterns: []
|
||||||
|
|
||||||
|
# advanced configuration option allowing to configure language server-specific options.
|
||||||
|
# Maps the language key to the options.
|
||||||
|
# Have a look at the docstring of the constructors of the LS implementations within solidlsp (e.g., for C# or PHP) to see which options are available.
|
||||||
|
# No documentation on options means no options are available.
|
||||||
|
ls_specific_settings: {}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ composer test # standard
|
|||||||
|
|
||||||
PHPUnit 9.6 via `phpunit.phar`. Bootstrap: `tests/bootstrap.php`. Config: `phpunit.xml`.
|
PHPUnit 9.6 via `phpunit.phar`. Bootstrap: `tests/bootstrap.php`. Config: `phpunit.xml`.
|
||||||
|
|
||||||
Current suite: **818 tests, 2275 assertions**.
|
Current suite: **821 tests, 2278 assertions**.
|
||||||
|
|
||||||
### Creating Updates
|
### Creating Updates
|
||||||
See `docs/UPDATE_INSTRUCTIONS.md` for the full procedure. Updates are ZIP packages in `updates/0.XX/`. Never include `*.md` files, `updates/changelog.php`, or root `.htaccess` in update ZIPs. ZIP structure must start directly from project directories — no version subfolder inside the archive.
|
See `docs/UPDATE_INSTRUCTIONS.md` for the full procedure. Updates are ZIP packages in `updates/0.XX/`. Never include `*.md` files, `updates/changelog.php`, or root `.htaccess` in update ZIPs. ZIP structure must start directly from project directories — no version subfolder inside the archive.
|
||||||
|
|||||||
@@ -130,10 +130,22 @@ class CronJobRepository
|
|||||||
*/
|
*/
|
||||||
public function markFailed($jobId, $error, $attempt = 1)
|
public function markFailed($jobId, $error, $attempt = 1)
|
||||||
{
|
{
|
||||||
$job = $this->db->get('pp_cron_jobs', ['max_attempts', 'attempts'], ['id' => $jobId]);
|
$job = $this->db->get('pp_cron_jobs', ['job_type', 'max_attempts', 'attempts'], ['id' => $jobId]);
|
||||||
|
|
||||||
$attempts = $job ? (int) $job['attempts'] : $attempt;
|
$attempts = $job ? (int) $job['attempts'] : $attempt;
|
||||||
$maxAttempts = $job ? (int) $job['max_attempts'] : 10;
|
$maxAttempts = $job ? (int) $job['max_attempts'] : 10;
|
||||||
|
$jobType = $job ? $job['job_type'] : '';
|
||||||
|
|
||||||
|
// Order-related Apilo joby — infinite retry co 30 min
|
||||||
|
if (CronJobType::isOrderRelatedApiloJob($jobType)) {
|
||||||
|
$nextRun = date('Y-m-d H:i:s', time() + CronJobType::APILO_ORDER_BACKOFF_SECONDS);
|
||||||
|
$this->db->update('pp_cron_jobs', [
|
||||||
|
'status' => CronJobType::STATUS_PENDING,
|
||||||
|
'last_error' => mb_substr($error, 0, 500),
|
||||||
|
'scheduled_at' => $nextRun,
|
||||||
|
], ['id' => $jobId]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($attempts >= $maxAttempts) {
|
if ($attempts >= $maxAttempts) {
|
||||||
// Przekroczono limit prób — trwale failed
|
// Przekroczono limit prób — trwale failed
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class CronJobType
|
|||||||
// Backoff
|
// Backoff
|
||||||
const BASE_BACKOFF_SECONDS = 60;
|
const BASE_BACKOFF_SECONDS = 60;
|
||||||
const MAX_BACKOFF_SECONDS = 3600;
|
const MAX_BACKOFF_SECONDS = 3600;
|
||||||
|
const APILO_ORDER_BACKOFF_SECONDS = 1800; // 30 min — stały interwał dla order jobów
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string[]
|
* @return string[]
|
||||||
@@ -69,6 +70,19 @@ class CronJobType
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $jobType
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isOrderRelatedApiloJob($jobType)
|
||||||
|
{
|
||||||
|
return in_array($jobType, [
|
||||||
|
self::APILO_SEND_ORDER,
|
||||||
|
self::APILO_SYNC_PAYMENT,
|
||||||
|
self::APILO_SYNC_STATUS,
|
||||||
|
], true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $attempt
|
* @param int $attempt
|
||||||
* @return int
|
* @return int
|
||||||
|
|||||||
@@ -1335,8 +1335,9 @@ class ProductRepository
|
|||||||
$this->saveImagesOrder( $productId, $d['gallery_order'] );
|
$this->saveImagesOrder( $productId, $d['gallery_order'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zapisz custom fields tylko gdy jawnie podane (partial update przez API może nie zawierać tego klucza)
|
// Zapisz custom fields tylko gdy formularz edycji renderował sekcję (marker hidden field)
|
||||||
if ( array_key_exists( 'custom_field_name', $d ) ) {
|
// API partial update nie zawiera tego markera — custom fields pominięte
|
||||||
|
if ( array_key_exists( 'custom_field_name_present', $d ) ) {
|
||||||
$this->saveCustomFields( $productId, $d['custom_field_name'] ?? [], $d['custom_field_type'] ?? [], $d['custom_field_required'] ?? [] );
|
$this->saveCustomFields( $productId, $d['custom_field_name'] ?? [], $d['custom_field_type'] ?? [], $d['custom_field_required'] ?? [] );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1753,6 +1754,8 @@ class ProductRepository
|
|||||||
$this->db->insert( 'pp_shop_products_custom_fields', [
|
$this->db->insert( 'pp_shop_products_custom_fields', [
|
||||||
'id_product' => $newProductId,
|
'id_product' => $newProductId,
|
||||||
'name' => $row['name'],
|
'name' => $row['name'],
|
||||||
|
'type' => $row['type'] ?? 'text',
|
||||||
|
'is_required' => $row['is_required'] ?? 0,
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -699,7 +699,8 @@ class ShopProductController
|
|||||||
|
|
||||||
private function renderCustomFieldsBox( array $product ): string
|
private function renderCustomFieldsBox( array $product ): string
|
||||||
{
|
{
|
||||||
$html = '<a href="#" class="btn btn-success" id="add_custom_field"><i class="fa fa-plus"></i> dodaj niestandardowe pole</a>';
|
$html = '<input type="hidden" name="custom_field_name_present" value="1">';
|
||||||
|
$html .= '<a href="#" class="btn btn-success" id="add_custom_field"><i class="fa fa-plus"></i> dodaj niestandardowe pole</a>';
|
||||||
$html .= '<div class="additional_fields pt-3">';
|
$html .= '<div class="additional_fields pt-3">';
|
||||||
|
|
||||||
$customFields = is_array( $product['custom_fields'] ?? null ) ? $product['custom_fields'] : [];
|
$customFields = is_array( $product['custom_fields'] ?? null ) ? $product['custom_fields'] : [];
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class ShopBasketController
|
|||||||
{
|
{
|
||||||
private const ORDER_SUBMIT_TOKEN_SESSION_KEY = 'order-submit-token';
|
private const ORDER_SUBMIT_TOKEN_SESSION_KEY = 'order-submit-token';
|
||||||
private const ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY = 'order-submit-last-order-id';
|
private const ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY = 'order-submit-last-order-id';
|
||||||
|
private const ORDER_SUBMIT_TOKEN_TTL = 1800;
|
||||||
|
|
||||||
public static $title = [
|
public static $title = [
|
||||||
'mainView' => 'Koszyk'
|
'mainView' => 'Koszyk'
|
||||||
@@ -276,19 +277,6 @@ class ShopBasketController
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$existingOrderId = isset( $_SESSION[ self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY ] )
|
|
||||||
? (int)$_SESSION[ self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY ]
|
|
||||||
: 0;
|
|
||||||
if ( $existingOrderId > 0 )
|
|
||||||
{
|
|
||||||
$existingOrderHash = $this->orderRepository->findHashById( $existingOrderId );
|
|
||||||
if ( $existingOrderHash )
|
|
||||||
{
|
|
||||||
header( 'Location: /zamowienie/' . $existingOrderHash );
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$client = \Shared\Helpers\Helpers::get_session( 'client' );
|
$client = \Shared\Helpers\Helpers::get_session( 'client' );
|
||||||
$orderSubmitToken = $this->createOrderSubmitToken();
|
$orderSubmitToken = $this->createOrderSubmitToken();
|
||||||
|
|
||||||
@@ -311,20 +299,23 @@ class ShopBasketController
|
|||||||
$orderSubmitToken = (string)\Shared\Helpers\Helpers::get( 'order_submit_token', true );
|
$orderSubmitToken = (string)\Shared\Helpers\Helpers::get( 'order_submit_token', true );
|
||||||
$existingOrderId = isset( $_SESSION[ self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY ] ) ? (int)$_SESSION[ self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY ] : 0;
|
$existingOrderId = isset( $_SESSION[ self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY ] ) ? (int)$_SESSION[ self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY ] : 0;
|
||||||
|
|
||||||
if ( !$this->isValidOrderSubmitToken( $orderSubmitToken ) )
|
$basket = \Shared\Helpers\Helpers::get_session( 'basket' );
|
||||||
{
|
if ( empty( $basket ) && $existingOrderId > 0 )
|
||||||
if ( $existingOrderId > 0 )
|
|
||||||
{
|
{
|
||||||
$existingOrderHash = $this->orderRepository->findHashById( $existingOrderId );
|
$existingOrderHash = $this->orderRepository->findHashById( $existingOrderId );
|
||||||
if ( $existingOrderHash )
|
if ( $existingOrderHash )
|
||||||
{
|
{
|
||||||
|
$this->logOrder( 'Double-submit detected, redirecting to existing order id=' . $existingOrderId );
|
||||||
header( 'Location: /zamowienie/' . $existingOrderHash );
|
header( 'Location: /zamowienie/' . $existingOrderHash );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !$this->isValidOrderSubmitToken( $orderSubmitToken ) )
|
||||||
|
{
|
||||||
|
$this->logOrder( 'Token validation failed. formToken=' . $orderSubmitToken . ' existingOrderId=' . $existingOrderId );
|
||||||
\Shared\Helpers\Helpers::error( \Shared\Helpers\Helpers::lang( 'zamowienie-zostalo-zlozone-komunikat-blad' ) );
|
\Shared\Helpers\Helpers::error( \Shared\Helpers\Helpers::lang( 'zamowienie-zostalo-zlozone-komunikat-blad' ) );
|
||||||
header( 'Location: /koszyk' );
|
header( 'Location: /koszyk-podsumowanie' );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,6 +358,7 @@ class ShopBasketController
|
|||||||
}
|
}
|
||||||
catch ( \Exception $e )
|
catch ( \Exception $e )
|
||||||
{
|
{
|
||||||
|
$this->logOrder( 'createFromBasket exception: ' . $e->getMessage() );
|
||||||
error_log( '[basketSave] createFromBasket exception: ' . $e->getMessage() );
|
error_log( '[basketSave] createFromBasket exception: ' . $e->getMessage() );
|
||||||
\Shared\Helpers\Helpers::error( \Shared\Helpers\Helpers::lang( 'zamowienie-zostalo-zlozone-komunikat-blad' ) );
|
\Shared\Helpers\Helpers::error( \Shared\Helpers\Helpers::lang( 'zamowienie-zostalo-zlozone-komunikat-blad' ) );
|
||||||
header( 'Location: /koszyk' );
|
header( 'Location: /koszyk' );
|
||||||
@@ -400,6 +392,7 @@ class ShopBasketController
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->logOrder( 'createFromBasket returned falsy order_id. client_id=' . ( $client['id'] ?? '?' ) . ' email=' . ( \Shared\Helpers\Helpers::get( 'email', true ) ?: '?' ) );
|
||||||
\Shared\Helpers\Helpers::error( \Shared\Helpers\Helpers::lang( 'zamowienie-zostalo-zlozone-komunikat-blad' ) );
|
\Shared\Helpers\Helpers::error( \Shared\Helpers\Helpers::lang( 'zamowienie-zostalo-zlozone-komunikat-blad' ) );
|
||||||
header( 'Location: /koszyk' );
|
header( 'Location: /koszyk' );
|
||||||
exit;
|
exit;
|
||||||
@@ -446,6 +439,79 @@ class ShopBasketController
|
|||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function basketUpdateCustomFields()
|
||||||
|
{
|
||||||
|
$basket = \Shared\Helpers\Helpers::get_session( 'basket' );
|
||||||
|
$product_code = \Shared\Helpers\Helpers::get( 'product_code' );
|
||||||
|
|
||||||
|
if ( !isset( $basket[ $product_code ] ) )
|
||||||
|
{
|
||||||
|
echo json_encode( [ 'result' => 'error', 'message' => 'Pozycja nie istnieje w koszyku' ] );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$position = $basket[ $product_code ];
|
||||||
|
$new_custom_fields = [];
|
||||||
|
$custom_fields_raw = \Shared\Helpers\Helpers::get( 'custom_field' );
|
||||||
|
|
||||||
|
if ( is_array( $custom_fields_raw ) )
|
||||||
|
{
|
||||||
|
foreach ( $custom_fields_raw as $field_id => $value )
|
||||||
|
{
|
||||||
|
$new_custom_fields[ (int)$field_id ] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$productRepo = new \Domain\Product\ProductRepository( $GLOBALS['mdb'] );
|
||||||
|
$missing_fields = [];
|
||||||
|
|
||||||
|
foreach ( $new_custom_fields as $field_id => $value )
|
||||||
|
{
|
||||||
|
$field_meta = $productRepo->findCustomFieldCached( $field_id );
|
||||||
|
if ( $field_meta && (int)$field_meta['is_required'] === 1 && trim( $value ) === '' )
|
||||||
|
{
|
||||||
|
$missing_fields[] = $field_meta['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( count( $missing_fields ) > 0 )
|
||||||
|
{
|
||||||
|
echo json_encode( [ 'result' => 'error', 'message' => 'Wypełnij wymagane pola: ' . implode( ', ', $missing_fields ) ] );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes_implode = '';
|
||||||
|
if ( isset( $position['attributes'] ) && is_array( $position['attributes'] ) && count( $position['attributes'] ) > 0 )
|
||||||
|
{
|
||||||
|
$attributes_implode = implode( '|', $position['attributes'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = isset( $position['message'] ) ? $position['message'] : '';
|
||||||
|
$new_product_code = md5( $position['product-id'] . $attributes_implode . $message . json_encode( $new_custom_fields ) );
|
||||||
|
|
||||||
|
if ( $new_product_code === $product_code )
|
||||||
|
{
|
||||||
|
$basket[ $product_code ]['custom_fields'] = $new_custom_fields;
|
||||||
|
}
|
||||||
|
elseif ( isset( $basket[ $new_product_code ] ) )
|
||||||
|
{
|
||||||
|
$basket[ $new_product_code ]['quantity'] += $position['quantity'];
|
||||||
|
unset( $basket[ $product_code ] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$position['custom_fields'] = $new_custom_fields;
|
||||||
|
$basket[ $new_product_code ] = $position;
|
||||||
|
unset( $basket[ $product_code ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
$basket = ( new \Domain\Promotion\PromotionRepository( $GLOBALS['mdb'] ) )->findPromotion( $basket );
|
||||||
|
\Shared\Helpers\Helpers::set_session( 'basket', $basket );
|
||||||
|
|
||||||
|
echo json_encode( [ 'result' => 'ok' ] );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
private function jsonBasketResponse( $basket, $coupon, $lang_id, $basket_transport_method_id )
|
private function jsonBasketResponse( $basket, $coupon, $lang_id, $basket_transport_method_id )
|
||||||
{
|
{
|
||||||
global $settings;
|
global $settings;
|
||||||
@@ -471,8 +537,23 @@ class ShopBasketController
|
|||||||
|
|
||||||
private function createOrderSubmitToken()
|
private function createOrderSubmitToken()
|
||||||
{
|
{
|
||||||
|
$sessionData = isset( $_SESSION[ self::ORDER_SUBMIT_TOKEN_SESSION_KEY ] )
|
||||||
|
? $_SESSION[ self::ORDER_SUBMIT_TOKEN_SESSION_KEY ]
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if ( is_array( $sessionData ) && isset( $sessionData['token'], $sessionData['created_at'] ) )
|
||||||
|
{
|
||||||
|
if ( ( time() - $sessionData['created_at'] ) < self::ORDER_SUBMIT_TOKEN_TTL )
|
||||||
|
{
|
||||||
|
return $sessionData['token'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$token = $this->generateOrderSubmitToken();
|
$token = $this->generateOrderSubmitToken();
|
||||||
\Shared\Helpers\Helpers::set_session( self::ORDER_SUBMIT_TOKEN_SESSION_KEY, $token );
|
\Shared\Helpers\Helpers::set_session( self::ORDER_SUBMIT_TOKEN_SESSION_KEY, [
|
||||||
|
'token' => $token,
|
||||||
|
'created_at' => time()
|
||||||
|
] );
|
||||||
\Shared\Helpers\Helpers::delete_session( self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY );
|
\Shared\Helpers\Helpers::delete_session( self::ORDER_SUBMIT_LAST_ORDER_ID_SESSION_KEY );
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
@@ -495,10 +576,29 @@ class ShopBasketController
|
|||||||
if ( !$token )
|
if ( !$token )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sessionToken = isset( $_SESSION[ self::ORDER_SUBMIT_TOKEN_SESSION_KEY ] ) ? (string)$_SESSION[ self::ORDER_SUBMIT_TOKEN_SESSION_KEY ] : '';
|
$sessionData = isset( $_SESSION[ self::ORDER_SUBMIT_TOKEN_SESSION_KEY ] )
|
||||||
if ( !$sessionToken )
|
? $_SESSION[ self::ORDER_SUBMIT_TOKEN_SESSION_KEY ]
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if ( !$sessionData )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Backward compatibility: stary format (plain string)
|
||||||
|
if ( is_string( $sessionData ) )
|
||||||
|
{
|
||||||
|
$sessionToken = $sessionData;
|
||||||
|
}
|
||||||
|
elseif ( is_array( $sessionData ) && isset( $sessionData['token'], $sessionData['created_at'] ) )
|
||||||
|
{
|
||||||
|
if ( ( time() - $sessionData['created_at'] ) >= self::ORDER_SUBMIT_TOKEN_TTL )
|
||||||
|
return false;
|
||||||
|
$sessionToken = $sessionData['token'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( function_exists( 'hash_equals' ) )
|
if ( function_exists( 'hash_equals' ) )
|
||||||
return hash_equals( $sessionToken, $token );
|
return hash_equals( $sessionToken, $token );
|
||||||
|
|
||||||
@@ -509,4 +609,11 @@ class ShopBasketController
|
|||||||
{
|
{
|
||||||
\Shared\Helpers\Helpers::delete_session( self::ORDER_SUBMIT_TOKEN_SESSION_KEY );
|
\Shared\Helpers\Helpers::delete_session( self::ORDER_SUBMIT_TOKEN_SESSION_KEY );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function logOrder( $message )
|
||||||
|
{
|
||||||
|
$logFile = __DIR__ . '/../../../logs/logs-order-' . date( 'Y-m-d' ) . '.log';
|
||||||
|
$line = '[' . date( 'Y-m-d H:i:s' ) . '] ' . $message . "\n";
|
||||||
|
@file_put_contents( $logFile, $line, FILE_APPEND );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,4 +19,9 @@ $config['trustmate']['enabled'] = true;
|
|||||||
$config['trustmate']['uid'] = '34eb36ba-c715-4cdc-8707-22376c9f14c7';
|
$config['trustmate']['uid'] = '34eb36ba-c715-4cdc-8707-22376c9f14c7';
|
||||||
|
|
||||||
$config['cron_key'] = 'Gi7FzWtkry19hZ1BqT1LKEWfwokQpigh';
|
$config['cron_key'] = 'Gi7FzWtkry19hZ1BqT1LKEWfwokQpigh';
|
||||||
|
|
||||||
|
$database_inst['host_remote'] = 'host700513.hostido.net.pl';
|
||||||
|
$database_inst['user'] = 'host700513_pomysloweprezenty-pl';
|
||||||
|
$database_inst['password'] = 'QBVbveHAzR78UN8pc7Um';
|
||||||
|
$database_inst['name'] = 'host700513_pomysloweprezenty-pl';
|
||||||
?>
|
?>
|
||||||
|
|||||||
63
cron.php
63
cron.php
@@ -521,6 +521,17 @@ $processor->registerHandler( \Domain\CronJob\CronJobType::APILO_SEND_ORDER, func
|
|||||||
{
|
{
|
||||||
$mdb->update( 'pp_shop_orders', [ 'apilo_order_id' => $response['id'] ], [ 'id' => $order['id'] ] );
|
$mdb->update( 'pp_shop_orders', [ 'apilo_order_id' => $response['id'] ], [ 'id' => $order['id'] ] );
|
||||||
\Domain\Integrations\ApiloLogger::log( $mdb, 'send_order', (int)$order['id'], 'Zamówienie wysłane do Apilo (apilo_order_id: ' . $response['id'] . ')', [ 'http_code' => $http_code_send, 'response' => $response ] );
|
\Domain\Integrations\ApiloLogger::log( $mdb, 'send_order', (int)$order['id'], 'Zamówienie wysłane do Apilo (apilo_order_id: ' . $response['id'] . ')', [ 'http_code' => $http_code_send, 'response' => $response ] );
|
||||||
|
|
||||||
|
// Wyczyść stare stuck joby sync_payment/sync_status dla tego zamówienia
|
||||||
|
$orderPayloadJson = json_encode(['order_id' => (int)$order['id']]);
|
||||||
|
$mdb->delete('pp_cron_jobs', [
|
||||||
|
'AND' => [
|
||||||
|
'job_type' => [\Domain\CronJob\CronJobType::APILO_SYNC_PAYMENT, \Domain\CronJob\CronJobType::APILO_SYNC_STATUS],
|
||||||
|
'payload' => $orderPayloadJson,
|
||||||
|
'status' => [\Domain\CronJob\CronJobType::STATUS_PENDING, \Domain\CronJob\CronJobType::STATUS_FAILED],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
echo '<p>Wysłałem zamówienie do apilo.com: ID: ' . $order['id'] . ' - ' . $response['id'] . '</p>';
|
echo '<p>Wysłałem zamówienie do apilo.com: ID: ' . $order['id'] . ' - ' . $response['id'] . '</p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -760,7 +771,8 @@ $processor->registerHandler( \Domain\CronJob\CronJobType::TRUSTMATE_INVITATION,
|
|||||||
|
|
||||||
$result = $processor->run( 20 );
|
$result = $processor->run( 20 );
|
||||||
|
|
||||||
// Powiadomienie mailowe o trwale nieudanych zadaniach Apilo
|
// Powiadomienie mailowe o problemach Apilo
|
||||||
|
// 1. Trwale failed joby (nie-order: token, product sync itp.)
|
||||||
$failedApiloJobs = $mdb->select('pp_cron_jobs', ['id', 'job_type', 'last_error', 'payload', 'attempts', 'completed_at'], [
|
$failedApiloJobs = $mdb->select('pp_cron_jobs', ['id', 'job_type', 'last_error', 'payload', 'attempts', 'completed_at'], [
|
||||||
'AND' => [
|
'AND' => [
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
@@ -768,16 +780,51 @@ $failedApiloJobs = $mdb->select('pp_cron_jobs', ['id', 'job_type', 'last_error',
|
|||||||
'completed_at[>=]' => date('Y-m-d H:i:s', time() - 120),
|
'completed_at[>=]' => date('Y-m-d H:i:s', time() - 120),
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
if (!empty($failedApiloJobs)) {
|
// 2. Order joby z wieloma próbami (infinite retry, ale wymagają uwagi)
|
||||||
$emailBody = "Następujące zadania Apilo zakończyły się trwałym błędem (wyczerpano limit prób):\n\n";
|
$stuckOrderJobs = $mdb->select('pp_cron_jobs', ['id', 'job_type', 'last_error', 'payload', 'attempts', 'scheduled_at'], [
|
||||||
foreach ($failedApiloJobs as $fj) {
|
'AND' => [
|
||||||
$emailBody .= "Job #" . $fj['id'] . " (" . $fj['job_type'] . ")\n";
|
'status' => 'pending',
|
||||||
$emailBody .= " Payload: " . $fj['payload'] . "\n";
|
'job_type' => [\Domain\CronJob\CronJobType::APILO_SEND_ORDER, \Domain\CronJob\CronJobType::APILO_SYNC_PAYMENT, \Domain\CronJob\CronJobType::APILO_SYNC_STATUS],
|
||||||
|
'attempts[>=]' => 10,
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$allProblems = array_merge($failedApiloJobs, $stuckOrderJobs);
|
||||||
|
if (!empty($allProblems)) {
|
||||||
|
$emailBody = "";
|
||||||
|
$orderNumbers = [];
|
||||||
|
|
||||||
|
foreach ($allProblems as $fj) {
|
||||||
|
$payloadData = is_string($fj['payload']) ? json_decode($fj['payload'], true) : $fj['payload'];
|
||||||
|
$orderId = isset($payloadData['order_id']) ? (int)$payloadData['order_id'] : 0;
|
||||||
|
$isOrderJob = \Domain\CronJob\CronJobType::isOrderRelatedApiloJob($fj['job_type']);
|
||||||
|
$statusLabel = $isOrderJob ? 'PONAWIANY CO 30 MIN' : 'TRWAŁY BŁĄD';
|
||||||
|
|
||||||
|
$emailBody .= "Job #" . $fj['id'] . " (" . $fj['job_type'] . ") — " . $statusLabel . "\n";
|
||||||
|
|
||||||
|
if ($orderId > 0) {
|
||||||
|
$order = $mdb->get('pp_shop_orders', ['id', 'client_name', 'client_surname', 'date_order', 'summary'], ['id' => $orderId]);
|
||||||
|
if ($order) {
|
||||||
|
$emailBody .= " Zamówienie: #" . $order['id'] . "\n";
|
||||||
|
$emailBody .= " Klient: " . trim($order['client_name'] . ' ' . $order['client_surname']) . "\n";
|
||||||
|
$emailBody .= " Data zamówienia: " . $order['date_order'] . "\n";
|
||||||
|
$emailBody .= " Kwota: " . $order['summary'] . " PLN\n";
|
||||||
|
$orderNumbers[] = '#' . $order['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$emailBody .= " Próby: " . $fj['attempts'] . "\n";
|
$emailBody .= " Próby: " . $fj['attempts'] . "\n";
|
||||||
$emailBody .= " Błąd: " . $fj['last_error'] . "\n";
|
$emailBody .= " Błąd: " . $fj['last_error'] . "\n";
|
||||||
$emailBody .= " Data: " . $fj['completed_at'] . "\n\n";
|
$emailBody .= " Data: " . ($fj['completed_at'] ? $fj['completed_at'] : $fj['scheduled_at']) . "\n\n";
|
||||||
}
|
}
|
||||||
\Shared\Helpers\Helpers::send_email('biuro@project-pro.pl', 'shopPRO: Trwały błąd synchronizacji Apilo (' . count($failedApiloJobs) . ' zadań)', $emailBody);
|
|
||||||
|
$subject = 'shopPRO: Problemy synchronizacji Apilo';
|
||||||
|
if (!empty($orderNumbers)) {
|
||||||
|
$subject .= ' — zamówienia ' . implode(', ', array_unique($orderNumbers));
|
||||||
|
}
|
||||||
|
$subject .= ' (' . count($allProblems) . ' zadań)';
|
||||||
|
|
||||||
|
\Shared\Helpers\Helpers::send_email('biuro@project-pro.pl', $subject, $emailBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<hr>';
|
echo '<hr>';
|
||||||
|
|||||||
@@ -4,6 +4,54 @@ Logi zmian z migracji na Domain-Driven Architecture. Najnowsze na gorze.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## ver. 0.346 (2026-04-16) - Fix usuwania wszystkich dodatkowych pól produktu
|
||||||
|
|
||||||
|
- **FIX**: `autoload/admin/Controllers/ShopProductController.php` — dodany hidden marker `custom_field_name_present` w `renderCustomFieldsBox()`, gwarantujący że sekcja custom fields jest zawsze rozpoznawana w POST nawet gdy wszystkie pola usunięte
|
||||||
|
- **FIX**: `autoload/Domain/Product/ProductRepository.php` — warunek zapisu custom fields zmieniony z `array_key_exists('custom_field_name')` na `array_key_exists('custom_field_name_present')` — naprawa buga gdzie jQuery `.serialize()` pomijał klucz pustej tablicy
|
||||||
|
- **NEW**: `tests/Unit/Domain/Product/ProductRepositoryTest.php` — test `testSaveCustomFieldsDeletesAllWhenEmpty` potwierdzający poprawne kasowanie wszystkich pól
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ver. 0.345 (2026-03-25) - DataLayer GA4 fix + checkout token fix
|
||||||
|
|
||||||
|
- **FIX**: `templates/shop-order/order-details.php` — event purchase: id→item_id (string), name→item_name, price via normalize_decimal (fix price:0), usunięty hardcoded value: 25.42, dodany google_business_vertical
|
||||||
|
- **FIX**: `templates/shop-basket/summary-view.php` — event begin_checkout: id→item_id, name→item_name, dodany google_business_vertical
|
||||||
|
- **FIX**: `templates/shop-product/product.php` — event view_item: dodany currency PLN, value, price jako number (nie string), google_business_vertical; event add_to_cart: dodany google_business_vertical, parseInt(quantity)
|
||||||
|
- **NEW**: `templates/shop-basket/basket.php` — nowy event view_cart na stronie koszyka z pełnym zestawem danych GA4 (item_id, item_name, price, quantity, currency, google_business_vertical)
|
||||||
|
- **FIX**: `autoload/front/Controllers/ShopBasketController.php` — usunięty błędny guard w summaryView() blokujący kolejne zamówienia po pierwszym (redirect na stare zamówienie zamiast podsumowanie)
|
||||||
|
- **FIX**: `autoload/front/Controllers/ShopBasketController.php` — token zamówienia z jednorazowego na TTL 30 min (wiele kart, odświeżenie, "wstecz" nie unieważniają formularza)
|
||||||
|
- **NEW**: `autoload/front/Controllers/ShopBasketController.php` — logowanie błędów zamówień do `logs/logs-order-YYYY-MM-DD.log` (double-submit, token invalid, exception, falsy order_id)
|
||||||
|
- **FIX**: `autoload/front/Controllers/ShopBasketController.php` — redirect przy złym tokenie na `/koszyk-podsumowanie` zamiast `/koszyk` (użytkownik nie traci kontekstu)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ver. 0.344 (2026-03-19) - Edycja personalizacji produktu w koszyku
|
||||||
|
|
||||||
|
- **NEW**: `autoload/front/Controllers/ShopBasketController.php` — nowa metoda `basketUpdateCustomFields()`: AJAX endpoint do edycji custom fields w koszyku z walidacją required, przeliczaniem product_code (MD5 hash) i merge duplikatów
|
||||||
|
- **NEW**: `templates/shop-basket/_partials/product-custom-fields.php` — przycisk "Edytuj personalizację" + formularz inline z aktualnymi wartościami
|
||||||
|
- **NEW**: `templates/shop-basket/basket-details.php` — przekazanie `product_code` do szablonu custom fields
|
||||||
|
- **NEW**: `templates/shop-basket/basket.php` — JavaScript obsługi edycji/zapisu/anulowania personalizacji
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ver. 0.343 (2026-03-19) - Custom fields: type + is_required + obsługa obrazków w koszyku
|
||||||
|
|
||||||
|
- **FIX**: `autoload/Domain/Product/ProductRepository.php` — kopiowanie custom fields przy duplikacji produktu uwzględnia teraz pola `type` i `is_required`
|
||||||
|
- **FIX**: `templates/shop-basket/_partials/product-custom-fields.php` — ochrona XSS (htmlspecialchars), obsługa pola typu `image`, bezpieczny fallback typu na `text`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ver. 0.342 (2026-03-19) - Apilo: email z danymi zamówienia + infinite retry dla order jobów
|
||||||
|
|
||||||
|
- **FIX**: `cron.php` — email notyfikacji Apilo zawiera teraz dane zamówienia (numer, klient, data, kwota) zamiast surowego JSON payload; temat emaila zawiera numery zamówień
|
||||||
|
- **NEW**: `autoload/Domain/CronJob/CronJobType.php` — `isOrderRelatedApiloJob()` identyfikuje order joby (send_order, sync_payment, sync_status)
|
||||||
|
- **NEW**: `autoload/Domain/CronJob/CronJobRepository.php` — order-related Apilo joby ponawiane w nieskończoność co 30 min zamiast permanent failure po 10 próbach
|
||||||
|
- **NEW**: `cron.php` — email rozróżnia "PONAWIANY CO 30 MIN" (order joby) vs "TRWAŁY BŁĄD" (inne joby)
|
||||||
|
- **NEW**: `cron.php` — po udanym wysłaniu zamówienia do Apilo czyszczone są stuck joby sync_payment/sync_status
|
||||||
|
- **TEST**: +2 testy infinite retry w `CronJobRepositoryTest`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## ver. 0.341 (2026-03-16) - Bugfix: zamówienia nie wysyłały się do Apilo + retry i powiadomienia
|
## ver. 0.341 (2026-03-16) - Bugfix: zamówienia nie wysyłały się do Apilo + retry i powiadomienia
|
||||||
|
|
||||||
- **FIX**: `cron.php` — dodano brakujące `$apiloRepository` do klauzul `use()` w 5 handlerach cron (APILO_TOKEN_KEEPALIVE, APILO_SEND_ORDER, APILO_PRODUCT_SYNC, APILO_PRICELIST_SYNC, APILO_STATUS_POLL); regresja z ver. 0.339 (split IntegrationsRepository → ApiloRepository) powodowała `Call to a member function apiloGetAccessToken() on null`
|
- **FIX**: `cron.php` — dodano brakujące `$apiloRepository` do klauzul `use()` w 5 handlerach cron (APILO_TOKEN_KEEPALIVE, APILO_SEND_ORDER, APILO_PRODUCT_SYNC, APILO_PRICELIST_SYNC, APILO_STATUS_POLL); regresja z ver. 0.339 (split IntegrationsRepository → ApiloRepository) powodowała `Call to a member function apiloGetAccessToken() on null`
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ composer test # standard
|
|||||||
## Aktualny stan
|
## Aktualny stan
|
||||||
|
|
||||||
```text
|
```text
|
||||||
OK (817 tests, 2271 assertions)
|
OK (821 tests, 2278 assertions)
|
||||||
```
|
```
|
||||||
|
|
||||||
Zweryfikowano: 2026-03-12 (ver. 0.337)
|
Zweryfikowano: 2026-04-16 (ver. 0.346)
|
||||||
|
|
||||||
## Konfiguracja
|
## Konfiguracja
|
||||||
|
|
||||||
|
|||||||
40
docs/TODO.md
40
docs/TODO.md
@@ -74,3 +74,43 @@ Dodać możliwość ustawienia limitu znaków w wiadomościach do produktu
|
|||||||
- [ ] [MINOR] cron.php:198 — Remove unused "$orderAdminService" local variable (php:S1481)
|
- [ ] [MINOR] cron.php:198 — Remove unused "$orderAdminService" local variable (php:S1481)
|
||||||
- [ ] [MINOR] cron.php:524 — Remove unused "$mdb" local variable (php:S1481)
|
- [ ] [MINOR] cron.php:524 — Remove unused "$mdb" local variable (php:S1481)
|
||||||
- [ ] [MINOR] cron.php:539 — Remove unused "$mdb" local variable (php:S1481)
|
- [ ] [MINOR] cron.php:539 — Remove unused "$mdb" local variable (php:S1481)
|
||||||
|
|
||||||
|
## SonarQube — 0.343 (2026-03-19)
|
||||||
|
|
||||||
|
### Nowe issues (nie występowały w 0.340)
|
||||||
|
|
||||||
|
#### Code Smells — CRITICAL
|
||||||
|
|
||||||
|
- [ ] [CRITICAL] autoload/admin/App.php:39 — Cognitive Complexity 37 (max 15) (php:S3776)
|
||||||
|
- [ ] [CRITICAL] autoload/admin/App.php:50 — Duplicated literal "Location: /admin/" 8 times (php:S1192)
|
||||||
|
- [ ] [CRITICAL] autoload/front/Controllers/ShopOrderController.php:86 — Cognitive Complexity 22 (max 15) (php:S3776)
|
||||||
|
- [ ] [CRITICAL] autoload/front/Controllers/ShopBasketController.php:275 — Duplicated literal "Location: /koszyk" 6 times (php:S1192)
|
||||||
|
- [ ] [CRITICAL] autoload/front/Controllers/ShopBasketController.php:287 — Duplicated literal "Location: /zamowienie/" 3 times (php:S1192)
|
||||||
|
- [ ] [CRITICAL] autoload/front/Controllers/ShopBasketController.php:495 — Add curly braces around nested statement(s) (php:S121)
|
||||||
|
- [ ] [CRITICAL] autoload/Domain/Integrations/IntegrationsRepository.php:33 — Add curly braces around nested statement(s) (php:S121)
|
||||||
|
- [ ] [CRITICAL] autoload/Domain/Integrations/ApiloRepository.php:449 — Cognitive Complexity 22 (max 15) (php:S3776)
|
||||||
|
- [ ] [CRITICAL] autoload/Domain/Order/OrderRepository.php:635 — Cognitive Complexity 61 (max 15) (php:S3776)
|
||||||
|
- [ ] [CRITICAL] cron.php:198 — Cognitive Complexity 109 (max 15) (php:S3776)
|
||||||
|
- [ ] [CRITICAL] cron.php:651 — Cognitive Complexity 18 (max 15) (php:S3776)
|
||||||
|
|
||||||
|
#### Code Smells — MAJOR
|
||||||
|
|
||||||
|
- [ ] [MAJOR] cron.php:198 — Function has 305 lines (max 150) (php:S138)
|
||||||
|
- [ ] [MAJOR] cron.php:572 — Unused function parameter "$payload" (php:S1172)
|
||||||
|
- [ ] [MAJOR] cron.php:572 — 5 returns (max 3) (php:S1142)
|
||||||
|
- [ ] [MAJOR] cron.php:605 — Unused function parameter "$payload" (php:S1172)
|
||||||
|
- [ ] [MAJOR] cron.php:605 — 4 returns (max 3) (php:S1142)
|
||||||
|
- [ ] [MAJOR] cron.php:651 — Unused function parameter "$payload" (php:S1172)
|
||||||
|
- [ ] [MAJOR] autoload/Domain/Integrations/ApiloRepository.php:53 — 4 returns (max 3) (php:S1142)
|
||||||
|
- [ ] [MAJOR] autoload/Domain/Integrations/ApiloRepository.php:93 — 4 returns (max 3) (php:S1142)
|
||||||
|
- [ ] [MAJOR] autoload/Domain/Integrations/ApiloRepository.php:105 — Merge if statement with enclosing one (php:S1066)
|
||||||
|
|
||||||
|
## SonarQube — 0.344 (2026-03-19)
|
||||||
|
|
||||||
|
- [ ] [MINOR] autoload/front/Controllers/ShopBasketController.php:484 — Use empty() to check whether the array is empty (php:S1155)
|
||||||
|
|
||||||
|
## SonarQube — 0.345 (2026-03-25)
|
||||||
|
|
||||||
|
- [ ] [MAJOR] autoload/front/Controllers/ShopBasketController.php:574 — This method has 6 returns, which is more than the 3 allowed (php:S1142)
|
||||||
|
- [ ] [CRITICAL] autoload/front/Controllers/ShopBasketController.php:576 — Add curly braces around nested statement(s) (php:S121)
|
||||||
|
- [ ] [CRITICAL] autoload/front/Controllers/ShopBasketController.php:602 — Add curly braces around nested statement(s) (php:S121)
|
||||||
81
temp/diagnose_apilo.php
Normal file
81
temp/diagnose_apilo.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Diagnostic script for Apilo integration on the instance DB
|
||||||
|
* Temporary — delete after diagnosis
|
||||||
|
*/
|
||||||
|
|
||||||
|
$db_host = 'host700513.hostido.net.pl';
|
||||||
|
$db_user = 'host700513_pomysloweprezenty-pl';
|
||||||
|
$db_pass = 'QBVbveHAzR78UN8pc7Um';
|
||||||
|
$db_name = 'host700513_pomysloweprezenty-pl';
|
||||||
|
|
||||||
|
$pdo = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8", $db_user, $db_pass);
|
||||||
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
|
||||||
|
echo "=== 1. APILO SETTINGS ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT name, LEFT(value, 200) as value FROM pp_shop_apilo_settings ORDER BY name");
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo sprintf(" %-35s = %s\n", $row['name'], $row['value']);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== 2. PENDING ORDERS (apilo_order_id IS NULL) ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT COUNT(*) as cnt FROM pp_shop_orders WHERE apilo_order_id IS NULL");
|
||||||
|
$row = $stmt->fetch();
|
||||||
|
echo " Total with NULL: " . $row['cnt'] . "\n";
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, date_order, status, apilo_order_id FROM pp_shop_orders WHERE apilo_order_id IS NULL ORDER BY date_order DESC LIMIT 10");
|
||||||
|
echo " Last 10 NULL orders:\n";
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo sprintf(" #%s date=%s status=%s\n", $row['id'], $row['date_order'], $row['status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== 3. FAILED ORDERS (apilo_order_id = -1) ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT COUNT(*) as cnt FROM pp_shop_orders WHERE apilo_order_id = -1");
|
||||||
|
$row = $stmt->fetch();
|
||||||
|
echo " Total with -1: " . $row['cnt'] . "\n";
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, date_order, status FROM pp_shop_orders WHERE apilo_order_id = -1 ORDER BY date_order DESC LIMIT 10");
|
||||||
|
echo " Last 10 failed orders:\n";
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo sprintf(" #%s date=%s status=%s\n", $row['id'], $row['date_order'], $row['status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== 4. SKIPPED ORDERS (apilo_order_id = -2) ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT COUNT(*) as cnt FROM pp_shop_orders WHERE apilo_order_id = -2");
|
||||||
|
$row = $stmt->fetch();
|
||||||
|
echo " Total with -2: " . $row['cnt'] . "\n";
|
||||||
|
|
||||||
|
echo "\n=== 5. RECENT APILO LOGS (pp_log) ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT id, action, order_id, message, date FROM pp_log WHERE action LIKE '%apilo%' OR action LIKE '%send_order%' OR action LIKE '%token%' OR action LIKE '%keepalive%' ORDER BY id DESC LIMIT 20");
|
||||||
|
$rows = $stmt->fetchAll();
|
||||||
|
if (empty($rows)) {
|
||||||
|
echo " No Apilo logs found in pp_log\n";
|
||||||
|
// Try broader search
|
||||||
|
$stmt = $pdo->query("SELECT id, action, order_id, message, date FROM pp_log ORDER BY id DESC LIMIT 10");
|
||||||
|
$rows = $stmt->fetchAll();
|
||||||
|
echo " Last 10 logs (any type):\n";
|
||||||
|
}
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
echo sprintf(" [%s] #%s action=%s order=%s msg=%s\n", $row['date'], $row['id'], $row['action'], $row['order_id'], substr($row['message'], 0, 120));
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== 6. CRON JOBS STATUS ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT job_type, status, COUNT(*) as cnt FROM pp_cron_jobs GROUP BY job_type, status ORDER BY job_type, status");
|
||||||
|
echo " Job type / status / count:\n";
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo sprintf(" %-30s %-12s %s\n", $row['job_type'], $row['status'], $row['cnt']);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== 7. RECENT CRON EXECUTIONS ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT id, job_type, status, created_at, processed_at FROM pp_cron_jobs ORDER BY id DESC LIMIT 15");
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo sprintf(" #%s type=%s status=%s created=%s processed=%s\n", $row['id'], $row['job_type'], $row['status'], $row['created_at'], $row['processed_at']);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== 8. SUCCESSFULLY SENT ORDERS (last 5) ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT id, date_order, apilo_order_id, status FROM pp_shop_orders WHERE apilo_order_id > 0 ORDER BY date_order DESC LIMIT 5");
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo sprintf(" #%s date=%s apilo_id=%s status=%s\n", $row['id'], $row['date_order'], $row['apilo_order_id'], $row['status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\nDone.\n";
|
||||||
49
temp/diagnose_apilo2.php
Normal file
49
temp/diagnose_apilo2.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
$pdo = new PDO("mysql:host=host700513.hostido.net.pl;dbname=host700513_pomysloweprezenty-pl;charset=utf8", 'host700513_pomysloweprezenty-pl', 'QBVbveHAzR78UN8pc7Um');
|
||||||
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
|
||||||
|
echo "=== CRON JOBS TABLE COLUMNS ===\n";
|
||||||
|
$stmt = $pdo->query("DESCRIBE pp_cron_jobs");
|
||||||
|
foreach ($stmt as $row) echo " " . $row['Field'] . " (" . $row['Type'] . ")\n";
|
||||||
|
|
||||||
|
echo "\n=== RECENT CRON JOBS (last 20) ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT * FROM pp_cron_jobs ORDER BY id DESC LIMIT 20");
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo " #" . $row['id'] . " type=" . $row['job_type'] . " status=" . $row['status'] . " created=" . ($row['created_at'] ?? $row['date'] ?? 'n/a') . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== PENDING CRON JOBS ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT * FROM pp_cron_jobs WHERE status = 'pending' ORDER BY id");
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo " #" . $row['id'] . " type=" . $row['job_type'];
|
||||||
|
foreach ($row as $k => $v) if ($v !== null && $k !== 'id' && $k !== 'job_type') echo " $k=$v";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== NULL ORDERS SINCE 2026-03-15 (after last successful sync) ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT id, date_order, status FROM pp_shop_orders WHERE apilo_order_id IS NULL AND date_order >= '2026-03-15 14:00:00' ORDER BY date_order ASC");
|
||||||
|
$rows = $stmt->fetchAll();
|
||||||
|
echo " Count: " . count($rows) . "\n";
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
echo sprintf(" #%s date=%s status=%s\n", $row['id'], $row['date_order'], $row['status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== NULL ORDERS COUNT BY DATE RANGE ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT
|
||||||
|
SUM(CASE WHEN date_order >= '2026-03-15 14:00:00' THEN 1 ELSE 0 END) as since_break,
|
||||||
|
SUM(CASE WHEN date_order >= '2024-08-20' AND date_order < '2026-03-15 14:00:00' THEN 1 ELSE 0 END) as before_break_after_sync_start,
|
||||||
|
SUM(CASE WHEN date_order < '2024-08-20' THEN 1 ELSE 0 END) as before_sync_start
|
||||||
|
FROM pp_shop_orders WHERE apilo_order_id IS NULL");
|
||||||
|
$row = $stmt->fetch();
|
||||||
|
echo " Since break (2026-03-15 14:00+): " . $row['since_break'] . "\n";
|
||||||
|
echo " Before break, after sync_start: " . $row['before_break_after_sync_start'] . "\n";
|
||||||
|
echo " Before sync_start (2024-08-20): " . $row['before_sync_start'] . "\n";
|
||||||
|
|
||||||
|
echo "\n=== LAST SUCCESSFUL SEND ORDER JOB ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT * FROM pp_cron_jobs WHERE job_type = 'apilo_send_order' AND status = 'completed' ORDER BY id DESC LIMIT 3");
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
foreach ($row as $k => $v) if ($v !== null) echo " $k=$v";
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\nDone.\n";
|
||||||
77
temp/fix_apilo_queue.php
Normal file
77
temp/fix_apilo_queue.php
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Fix stuck Apilo cron jobs on the instance after deploying the closure fix.
|
||||||
|
* Run once after uploading the fixed cron.php.
|
||||||
|
*
|
||||||
|
* Temporary — delete after use.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$pdo = new PDO("mysql:host=host700513.hostido.net.pl;dbname=host700513_pomysloweprezenty-pl;charset=utf8", 'host700513_pomysloweprezenty-pl', 'QBVbveHAzR78UN8pc7Um');
|
||||||
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
|
||||||
|
echo "=== BEFORE FIX ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT job_type, status, COUNT(*) as cnt FROM pp_cron_jobs WHERE status IN ('pending','processing','failed') GROUP BY job_type, status ORDER BY job_type");
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo " {$row['job_type']} {$row['status']} {$row['cnt']}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. Reset the stuck apilo_send_order job (attempts back to 0, clear error)
|
||||||
|
echo "\n=== Resetting apilo_send_order pending jobs ===\n";
|
||||||
|
$stmt = $pdo->prepare("UPDATE pp_cron_jobs SET attempts = 0, last_error = NULL, scheduled_at = NOW() WHERE job_type = 'apilo_send_order' AND status = 'pending'");
|
||||||
|
$stmt->execute();
|
||||||
|
echo " Reset {$stmt->rowCount()} apilo_send_order jobs\n";
|
||||||
|
|
||||||
|
// 2. Reset token keepalive failed jobs
|
||||||
|
echo "\n=== Resetting apilo_token_keepalive failed jobs ===\n";
|
||||||
|
$stmt = $pdo->prepare("UPDATE pp_cron_jobs SET attempts = 0, last_error = NULL, status = 'pending', scheduled_at = NOW() WHERE job_type = 'apilo_token_keepalive' AND status = 'failed'");
|
||||||
|
$stmt->execute();
|
||||||
|
echo " Reset {$stmt->rowCount()} token keepalive jobs\n";
|
||||||
|
|
||||||
|
// 3. Cancel sync_payment and sync_status jobs for orders that haven't been sent yet
|
||||||
|
// (these orders have apilo_order_id = NULL so sync is pointless — they'll be re-queued after order is sent)
|
||||||
|
echo "\n=== Cancelling premature sync jobs for unsent orders ===\n";
|
||||||
|
$stmt = $pdo->query("
|
||||||
|
SELECT cj.id, cj.job_type, cj.payload
|
||||||
|
FROM pp_cron_jobs cj
|
||||||
|
WHERE cj.status = 'pending'
|
||||||
|
AND cj.job_type IN ('apilo_sync_payment', 'apilo_sync_status')
|
||||||
|
");
|
||||||
|
$to_cancel = [];
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
$payload = json_decode($row['payload'], true);
|
||||||
|
$order_id = $payload['order_id'] ?? 0;
|
||||||
|
// Check if this order has been sent to Apilo
|
||||||
|
$check = $pdo->prepare("SELECT apilo_order_id FROM pp_shop_orders WHERE id = ?");
|
||||||
|
$check->execute([$order_id]);
|
||||||
|
$order = $check->fetch();
|
||||||
|
if ($order && ($order['apilo_order_id'] === null || (int)$order['apilo_order_id'] <= 0)) {
|
||||||
|
$to_cancel[] = $row['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($to_cancel) {
|
||||||
|
$ids = implode(',', $to_cancel);
|
||||||
|
$pdo->exec("UPDATE pp_cron_jobs SET status = 'cancelled' WHERE id IN ($ids)");
|
||||||
|
echo " Cancelled " . count($to_cancel) . " premature sync jobs\n";
|
||||||
|
} else {
|
||||||
|
echo " No premature sync jobs to cancel\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Reset failed product_sync, pricelist_sync, status_poll jobs
|
||||||
|
echo "\n=== Resetting other failed Apilo jobs ===\n";
|
||||||
|
$stmt = $pdo->prepare("UPDATE pp_cron_jobs SET attempts = 0, last_error = NULL, scheduled_at = NOW() WHERE job_type IN ('apilo_product_sync', 'apilo_pricelist_sync', 'apilo_status_poll') AND status = 'pending'");
|
||||||
|
$stmt->execute();
|
||||||
|
echo " Reset {$stmt->rowCount()} other Apilo pending jobs\n";
|
||||||
|
|
||||||
|
echo "\n=== AFTER FIX ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT job_type, status, COUNT(*) as cnt FROM pp_cron_jobs WHERE status IN ('pending','processing','failed') GROUP BY job_type, status ORDER BY job_type");
|
||||||
|
foreach ($stmt as $row) {
|
||||||
|
echo " {$row['job_type']} {$row['status']} {$row['cnt']}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n=== ORDERS NEEDING SEND (apilo_order_id IS NULL, after sync_start) ===\n";
|
||||||
|
$stmt = $pdo->query("SELECT COUNT(*) as cnt FROM pp_shop_orders WHERE apilo_order_id IS NULL AND date_order >= '2024-08-20'");
|
||||||
|
$row = $stmt->fetch();
|
||||||
|
echo " " . $row['cnt'] . " orders to send\n";
|
||||||
|
echo " (cron processes 1 per run, should catch up within " . $row['cnt'] . " cron cycles)\n";
|
||||||
|
|
||||||
|
echo "\nDone. Deploy fixed cron.php to instance, then run this script.\n";
|
||||||
70
temp/rebuild_changelog_html.php
Normal file
70
temp/rebuild_changelog_html.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Rebuild changelog-data.html from docs/CHANGELOG.md
|
||||||
|
* One-time script — delete after use.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$md = file_get_contents(__DIR__ . '/../docs/CHANGELOG.md');
|
||||||
|
$lines = explode("\n", $md);
|
||||||
|
|
||||||
|
$entries = [];
|
||||||
|
$currentVersion = null;
|
||||||
|
$currentDate = null;
|
||||||
|
$currentLines = [];
|
||||||
|
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
// Match: ## ver. 0.341 (2026-03-16) - Description here
|
||||||
|
if (preg_match('/^## ver\. ([\d.]+) \((\d{4}-\d{2}-\d{2})\) - (.+)$/', $line, $m)) {
|
||||||
|
// Save previous entry
|
||||||
|
if ($currentVersion !== null) {
|
||||||
|
$entries[] = [
|
||||||
|
'version' => $currentVersion,
|
||||||
|
'date' => $currentDate,
|
||||||
|
'lines' => $currentLines,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$currentVersion = $m[1];
|
||||||
|
$currentDate = $m[2];
|
||||||
|
$currentLines = [];
|
||||||
|
} elseif ($currentVersion !== null && trim($line) !== '' && trim($line) !== '---') {
|
||||||
|
// Clean markdown formatting for HTML
|
||||||
|
$clean = $line;
|
||||||
|
$clean = preg_replace('/^\- \*\*([A-Z]+)\*\*: /', '$1 - ', $clean);
|
||||||
|
$clean = preg_replace('/`([^`]+)`/', '$1', $clean);
|
||||||
|
$clean = str_replace(['**', '__'], '', $clean);
|
||||||
|
$clean = trim($clean);
|
||||||
|
if ($clean) {
|
||||||
|
$currentLines[] = $clean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Last entry
|
||||||
|
if ($currentVersion !== null) {
|
||||||
|
$entries[] = [
|
||||||
|
'version' => $currentVersion,
|
||||||
|
'date' => $currentDate,
|
||||||
|
'lines' => $currentLines,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build HTML
|
||||||
|
$html = '';
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
$dateParts = explode('-', $entry['date']);
|
||||||
|
$dateFormatted = $dateParts[2] . '.' . $dateParts[1] . '.' . $dateParts[0];
|
||||||
|
|
||||||
|
$desc = implode("\n", $entry['lines']);
|
||||||
|
$desc = htmlspecialchars($desc, ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
|
$html .= '<b>ver. ' . $entry['version'] . ' - ' . $dateFormatted . '</b><br />' . "\n";
|
||||||
|
$html .= $desc . "\n";
|
||||||
|
$html .= '<hr>' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$outPath = __DIR__ . '/../updates/changelog-data.html';
|
||||||
|
file_put_contents($outPath, $html);
|
||||||
|
|
||||||
|
$size = filesize($outPath);
|
||||||
|
echo "Generated " . count($entries) . " entries\n";
|
||||||
|
echo "File size: " . number_format($size) . " bytes\n";
|
||||||
|
echo "Output: $outPath\n";
|
||||||
@@ -1,20 +1,52 @@
|
|||||||
<? if ( $this -> custom_fields ) : ?>
|
<? if ( $this -> custom_fields ) : ?>
|
||||||
|
<div class="custom-fields-display" data-product-code="<?= htmlspecialchars( $this->product_code ); ?>">
|
||||||
<? foreach ( $this -> custom_fields as $key => $val ) : ?>
|
<? foreach ( $this -> custom_fields as $key => $val ) : ?>
|
||||||
<? $custom_field = ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->findCustomFieldCached( $key ); ?>
|
<? $custom_field = ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->findCustomFieldCached( $key ); ?>
|
||||||
|
<? $field_type = !empty( $custom_field['type'] ) ? $custom_field['type'] : 'text'; ?>
|
||||||
|
|
||||||
<? if ( $custom_field['type'] == 'text' ) : ?>
|
<? if ( $field_type == 'text' ) : ?>
|
||||||
<div class="custom-field">
|
<div class="custom-field">
|
||||||
<div class="_name">
|
<div class="_name">
|
||||||
<?
|
<?= htmlspecialchars( $custom_field['name'] ) . ':'; ?>
|
||||||
echo $custom_field['name'] . ':';
|
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="_text">
|
<div class="_text">
|
||||||
<?= $val;?>
|
<?= nl2br( htmlspecialchars( $val ) );?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<? elseif ( $field_type == 'image' && !empty( $val ) ) : ?>
|
||||||
|
<div class="custom-field">
|
||||||
|
<div class="_name">
|
||||||
|
<?= htmlspecialchars( $custom_field['name'] ) . ':'; ?>
|
||||||
|
</div>
|
||||||
|
<div class="_image">
|
||||||
|
<img src="<?= htmlspecialchars( $val );?>" alt="<?= htmlspecialchars( $custom_field['name'] );?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<? elseif ( $custom_field['type'] == 'image' ) : ?>
|
|
||||||
|
|
||||||
<? endif; ?>
|
<? endif; ?>
|
||||||
<? endforeach; ?>
|
<? endforeach; ?>
|
||||||
|
<a href="#" class="btn btn-sm btn-default btn-edit-custom-fields">Edytuj personalizację</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="custom-fields-edit" data-product-code="<?= htmlspecialchars( $this->product_code ); ?>" style="display: none;">
|
||||||
|
<? foreach ( $this -> custom_fields as $key => $val ) : ?>
|
||||||
|
<? $custom_field = ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->findCustomFieldCached( $key ); ?>
|
||||||
|
<? $field_type = !empty( $custom_field['type'] ) ? $custom_field['type'] : 'text'; ?>
|
||||||
|
<? $is_required = !empty( $custom_field['is_required'] ) ? (int)$custom_field['is_required'] : 0; ?>
|
||||||
|
|
||||||
|
<div class="custom-field-edit-row" style="margin-bottom: 5px;">
|
||||||
|
<label>
|
||||||
|
<?= htmlspecialchars( $custom_field['name'] ); ?><?= $is_required ? ' <span style="color:red;">*</span>' : ''; ?>
|
||||||
|
</label>
|
||||||
|
<? if ( $field_type == 'text' ) : ?>
|
||||||
|
<input type="text" class="form-control form-control-sm" name="custom_field[<?= (int)$key; ?>]" value="<?= htmlspecialchars( $val ); ?>" <?= $is_required ? 'required' : ''; ?>>
|
||||||
|
<? elseif ( $field_type == 'image' ) : ?>
|
||||||
|
<input type="text" class="form-control form-control-sm" name="custom_field[<?= (int)$key; ?>]" value="<?= htmlspecialchars( $val ); ?>" placeholder="URL obrazka" <?= $is_required ? 'required' : ''; ?>>
|
||||||
|
<? endif; ?>
|
||||||
|
</div>
|
||||||
|
<? endforeach; ?>
|
||||||
|
<div style="margin-top: 5px;">
|
||||||
|
<a href="#" class="btn btn-sm btn-primary btn-save-custom-fields">Zapisz</a>
|
||||||
|
<a href="#" class="btn btn-sm btn-default btn-cancel-custom-fields">Anuluj</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<? endif; ?>
|
<? endif; ?>
|
||||||
@@ -61,7 +61,8 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<? endif; ?>
|
<? endif; ?>
|
||||||
<?= \Shared\Tpl\Tpl::view( 'shop-basket/_partials/product-custom-fields', [
|
<?= \Shared\Tpl\Tpl::view( 'shop-basket/_partials/product-custom-fields', [
|
||||||
'custom_fields' => $position['custom_fields']
|
'custom_fields' => $position['custom_fields'],
|
||||||
|
'product_code' => $position_hash
|
||||||
] ); ?>
|
] ); ?>
|
||||||
<? if ( $product['additional_message'] ):?>
|
<? if ( $product['additional_message'] ):?>
|
||||||
<div class="basket-product-message">
|
<div class="basket-product-message">
|
||||||
|
|||||||
@@ -1,4 +1,46 @@
|
|||||||
<? global $settings; ?>
|
<? global $settings; ?>
|
||||||
|
<?
|
||||||
|
if ( $settings['google_tag_manager_id'] && is_array( $this -> basket ) && count( $this -> basket ) ):
|
||||||
|
$view_cart_items = '';
|
||||||
|
$view_cart_value = 0;
|
||||||
|
|
||||||
|
foreach ( $this -> basket as $position ):
|
||||||
|
$vc_product = (new \Domain\Product\ProductRepository($GLOBALS['mdb']))->findCached( (int)$position['product-id'], (new \Domain\Languages\LanguagesRepository($GLOBALS['mdb']))->defaultLanguage() );
|
||||||
|
|
||||||
|
if ( !$vc_product )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$vc_price = (float)$vc_product['price_brutto_promo'] > 0 && (float)$vc_product['price_brutto_promo'] < (float)$vc_product['price_brutto']
|
||||||
|
? (float)$vc_product['price_brutto_promo']
|
||||||
|
: (float)$vc_product['price_brutto'];
|
||||||
|
|
||||||
|
$vc_qty = (int)$position['quantity'];
|
||||||
|
$view_cart_value += $vc_price * $vc_qty;
|
||||||
|
|
||||||
|
if ( $view_cart_items )
|
||||||
|
$view_cart_items .= ',';
|
||||||
|
|
||||||
|
$view_cart_items .= '{';
|
||||||
|
$view_cart_items .= 'item_id: "' . $vc_product['id'] . '",';
|
||||||
|
$view_cart_items .= 'item_name: "' . str_replace( '"', '', $vc_product['language']['name'] ) . '",';
|
||||||
|
$view_cart_items .= 'price: ' . \Shared\Helpers\Helpers::normalize_decimal( $vc_price ) . ',';
|
||||||
|
$view_cart_items .= 'quantity: ' . $vc_qty . ',';
|
||||||
|
$view_cart_items .= 'google_business_vertical: "retail"';
|
||||||
|
$view_cart_items .= '}';
|
||||||
|
endforeach;
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
dataLayer.push({ ecommerce: null });
|
||||||
|
dataLayer.push({
|
||||||
|
event: "view_cart",
|
||||||
|
ecommerce: {
|
||||||
|
currency: "PLN",
|
||||||
|
value: <?= \Shared\Helpers\Helpers::normalize_decimal( $view_cart_value );?>,
|
||||||
|
items: [<?= $view_cart_items;?>]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<? endif; ?>
|
||||||
<div id="basket-container">
|
<div id="basket-container">
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<?= $this->basket_details; ?>
|
<?= $this->basket_details; ?>
|
||||||
@@ -508,4 +550,62 @@
|
|||||||
console.warn('#orlen_point_id nie został znaleziony.');
|
console.warn('#orlen_point_id nie został znaleziony.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// edycja personalizacji produktu w koszyku
|
||||||
|
$(document).on('click', '.btn-edit-custom-fields', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var $display = $(this).closest('.custom-fields-display');
|
||||||
|
var productCode = $display.data('product-code');
|
||||||
|
$display.hide();
|
||||||
|
$display.siblings('.custom-fields-edit[data-product-code="' + productCode + '"]').show();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-cancel-custom-fields', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var $edit = $(this).closest('.custom-fields-edit');
|
||||||
|
var productCode = $edit.data('product-code');
|
||||||
|
$edit.hide();
|
||||||
|
$edit.siblings('.custom-fields-display[data-product-code="' + productCode + '"]').show();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-save-custom-fields', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var $edit = $(this).closest('.custom-fields-edit');
|
||||||
|
var productCode = $edit.data('product-code');
|
||||||
|
|
||||||
|
var valid = true;
|
||||||
|
$edit.find('input[required]').each(function() {
|
||||||
|
if ($.trim($(this).val()) === '') {
|
||||||
|
$(this).css('border-color', 'red');
|
||||||
|
valid = false;
|
||||||
|
} else {
|
||||||
|
$(this).css('border-color', '');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!valid) {
|
||||||
|
alert('Wypełnij wszystkie wymagane pola');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formData = { product_code: productCode };
|
||||||
|
$edit.find('input[name^="custom_field"]').each(function() {
|
||||||
|
formData[$(this).attr('name')] = $(this).val();
|
||||||
|
});
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
cache: false,
|
||||||
|
url: '/shopBasket/basket_update_custom_fields',
|
||||||
|
data: formData,
|
||||||
|
success: function(response) {
|
||||||
|
var data = jQuery.parseJSON(response);
|
||||||
|
if (data.result === 'ok') {
|
||||||
|
location.reload();
|
||||||
|
} else {
|
||||||
|
alert(data.message || 'Wystąpił błąd');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -73,10 +73,11 @@
|
|||||||
$begin_checkout_items .= ',';
|
$begin_checkout_items .= ',';
|
||||||
|
|
||||||
$begin_checkout_items .= '{';
|
$begin_checkout_items .= '{';
|
||||||
$begin_checkout_items .= '"id": "' . $product['id'] . '",';
|
$begin_checkout_items .= '"item_id": "' . $product['id'] . '",';
|
||||||
$begin_checkout_items .= '"name": "' . $product['language']['name'] . '",';
|
$begin_checkout_items .= '"item_name": "' . str_replace( '"', '', $product['language']['name'] ) . '",';
|
||||||
$begin_checkout_items .= '"price": ' . \Shared\Helpers\Helpers::normalize_decimal( $price_product['price_new'] ) . ',';
|
$begin_checkout_items .= '"price": ' . \Shared\Helpers\Helpers::normalize_decimal( $price_product['price_new'] ) . ',';
|
||||||
$begin_checkout_items .= '"quantity": ' . $position['quantity'];
|
$begin_checkout_items .= '"quantity": ' . (int)$position['quantity'] . ',';
|
||||||
|
$begin_checkout_items .= '"google_business_vertical": "retail"';
|
||||||
$begin_checkout_items .= '}';
|
$begin_checkout_items .= '}';
|
||||||
?>
|
?>
|
||||||
<? endforeach;?>
|
<? endforeach;?>
|
||||||
|
|||||||
@@ -169,17 +169,17 @@
|
|||||||
event: "purchase",
|
event: "purchase",
|
||||||
ecommerce: {
|
ecommerce: {
|
||||||
transaction_id: "<?= $this -> order['id'];?>",
|
transaction_id: "<?= $this -> order['id'];?>",
|
||||||
value: 25.42,
|
|
||||||
currency: "PLN",
|
currency: "PLN",
|
||||||
value: <?= \Shared\Helpers\Helpers::normalize_decimal( round( $this -> order['summary'], 2 ) ) - str_replace( ',', '.', round( $this -> order['transport_cost'], 2 ) );?>,
|
value: <?= \Shared\Helpers\Helpers::normalize_decimal( round( $this -> order['summary'], 2 ) ) - str_replace( ',', '.', round( $this -> order['transport_cost'], 2 ) );?>,
|
||||||
shipping: <?= \Shared\Helpers\Helpers::normalize_decimal( $this -> order['transport_cost'] );?>,
|
shipping: <?= \Shared\Helpers\Helpers::normalize_decimal( $this -> order['transport_cost'] );?>,
|
||||||
items: [
|
items: [
|
||||||
<? foreach ( $this -> order['products'] as $product ):?>
|
<? foreach ( $this -> order['products'] as $product ):?>
|
||||||
{
|
{
|
||||||
'id': <?= (int)$product['product_id'];?>,
|
item_id: "<?= $product['product_id'];?>",
|
||||||
'name': '<?= $product['name'];?>',
|
item_name: "<?= str_replace( '"', '', $product['name'] );?>",
|
||||||
'quantity': <?= $product['quantity'];?>,
|
quantity: <?= (int)$product['quantity'];?>,
|
||||||
'price': <?= ((float)$product['price_brutto_promo'] > 0 && (float)$product['price_brutto_promo'] < (float)$product['price_brutto']) ? (float)$product['price_brutto_promo'] : (float)$product['price_brutto'];?>
|
price: <?= ((float)$product['price_brutto_promo'] > 0 && (float)$product['price_brutto_promo'] < (float)$product['price_brutto']) ? \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto_promo'] ) : \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] );?>,
|
||||||
|
google_business_vertical: "retail"
|
||||||
}<? if ( $product != end( $this -> order['products'] ) ) echo ',';?>
|
}<? if ( $product != end( $this -> order['products'] ) ) echo ',';?>
|
||||||
<? endforeach;?>
|
<? endforeach;?>
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -275,12 +275,15 @@
|
|||||||
dataLayer.push({
|
dataLayer.push({
|
||||||
event: "view_item",
|
event: "view_item",
|
||||||
ecommerce: {
|
ecommerce: {
|
||||||
|
currency: "PLN",
|
||||||
|
value: <? if ( $this -> product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?>,
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
item_id: "<?= $this -> product['id'];?>",
|
item_id: "<?= $this -> product['id'];?>",
|
||||||
item_name: "<?= str_replace( '"', '', $this -> product['language']['name'] );?>",
|
item_name: "<?= str_replace( '"', '', $this -> product['language']['name'] );?>",
|
||||||
price: '<? if ( $this -> product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?>',
|
price: <? if ( $this -> product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?>,
|
||||||
quantity: 1
|
quantity: 1,
|
||||||
|
google_business_vertical: "retail"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -617,7 +620,8 @@
|
|||||||
item_id: "<?= $this -> product['id'];?>",
|
item_id: "<?= $this -> product['id'];?>",
|
||||||
item_name: "<?= str_replace( '"', '', $this -> product['language']['name'] );?>",
|
item_name: "<?= str_replace( '"', '', $this -> product['language']['name'] );?>",
|
||||||
price: <? if ( $this -> product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?>,
|
price: <? if ( $this -> product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?>,
|
||||||
quantity: quantity
|
quantity: parseInt(quantity),
|
||||||
|
google_business_vertical: "retail"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ class CronJobRepositoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
// Job with attempts < max_attempts → reschedule with backoff
|
// Job with attempts < max_attempts → reschedule with backoff
|
||||||
$this->mockDb->method('get')->willReturn([
|
$this->mockDb->method('get')->willReturn([
|
||||||
|
'job_type' => 'price_history',
|
||||||
'max_attempts' => 10,
|
'max_attempts' => 10,
|
||||||
'attempts' => 2,
|
'attempts' => 2,
|
||||||
]);
|
]);
|
||||||
@@ -228,6 +229,7 @@ class CronJobRepositoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
// Job with attempts >= max_attempts → permanent failure
|
// Job with attempts >= max_attempts → permanent failure
|
||||||
$this->mockDb->method('get')->willReturn([
|
$this->mockDb->method('get')->willReturn([
|
||||||
|
'job_type' => 'price_history',
|
||||||
'max_attempts' => 3,
|
'max_attempts' => 3,
|
||||||
'attempts' => 3,
|
'attempts' => 3,
|
||||||
]);
|
]);
|
||||||
@@ -249,6 +251,7 @@ class CronJobRepositoryTest extends TestCase
|
|||||||
public function testMarkFailedTruncatesErrorTo500Chars(): void
|
public function testMarkFailedTruncatesErrorTo500Chars(): void
|
||||||
{
|
{
|
||||||
$this->mockDb->method('get')->willReturn([
|
$this->mockDb->method('get')->willReturn([
|
||||||
|
'job_type' => 'price_history',
|
||||||
'max_attempts' => 10,
|
'max_attempts' => 10,
|
||||||
'attempts' => 1,
|
'attempts' => 1,
|
||||||
]);
|
]);
|
||||||
@@ -268,6 +271,51 @@ class CronJobRepositoryTest extends TestCase
|
|||||||
$this->repo->markFailed(1, $longError);
|
$this->repo->markFailed(1, $longError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMarkFailedApiloOrderJobNeverPermanentlyFails(): void
|
||||||
|
{
|
||||||
|
// apilo_send_order with max attempts reached → still pending (infinite retry)
|
||||||
|
$this->mockDb->method('get')->willReturn([
|
||||||
|
'job_type' => 'apilo_send_order',
|
||||||
|
'max_attempts' => 10,
|
||||||
|
'attempts' => 15,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->mockDb->expects($this->once())
|
||||||
|
->method('update')
|
||||||
|
->with(
|
||||||
|
'pp_cron_jobs',
|
||||||
|
$this->callback(function ($data) {
|
||||||
|
return $data['status'] === 'pending'
|
||||||
|
&& isset($data['scheduled_at'])
|
||||||
|
&& isset($data['last_error']);
|
||||||
|
}),
|
||||||
|
['id' => 5]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->repo->markFailed(5, 'API timeout');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMarkFailedApiloSyncPaymentInfiniteRetry(): void
|
||||||
|
{
|
||||||
|
$this->mockDb->method('get')->willReturn([
|
||||||
|
'job_type' => 'apilo_sync_payment',
|
||||||
|
'max_attempts' => 10,
|
||||||
|
'attempts' => 10,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->mockDb->expects($this->once())
|
||||||
|
->method('update')
|
||||||
|
->with(
|
||||||
|
'pp_cron_jobs',
|
||||||
|
$this->callback(function ($data) {
|
||||||
|
return $data['status'] === 'pending';
|
||||||
|
}),
|
||||||
|
['id' => 6]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->repo->markFailed(6, 'Apilo unavailable');
|
||||||
|
}
|
||||||
|
|
||||||
// --- hasPendingJob ---
|
// --- hasPendingJob ---
|
||||||
|
|
||||||
public function testHasPendingJobReturnsTrueWhenExists(): void
|
public function testHasPendingJobReturnsTrueWhenExists(): void
|
||||||
|
|||||||
@@ -1292,4 +1292,25 @@ class ProductRepositoryTest extends TestCase
|
|||||||
|
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSaveCustomFieldsDeletesAllWhenEmpty(): void
|
||||||
|
{
|
||||||
|
$mockDb = $this->createMock(\medoo::class);
|
||||||
|
|
||||||
|
$mockDb->expects($this->once())
|
||||||
|
->method('delete')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('pp_shop_products_custom_fields'),
|
||||||
|
$this->equalTo(['id_product' => 55])
|
||||||
|
);
|
||||||
|
|
||||||
|
$mockDb->expects($this->never())->method('insert');
|
||||||
|
$mockDb->expects($this->never())->method('update');
|
||||||
|
|
||||||
|
$repository = new ProductRepository($mockDb);
|
||||||
|
|
||||||
|
$method = new \ReflectionMethod(ProductRepository::class, 'saveCustomFields');
|
||||||
|
$method->setAccessible(true);
|
||||||
|
$method->invoke($repository, 55, [], [], []);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
updates/0.30/ver_0.342.zip
Normal file
BIN
updates/0.30/ver_0.342.zip
Normal file
Binary file not shown.
25
updates/0.30/ver_0.342_manifest.json
Normal file
25
updates/0.30/ver_0.342_manifest.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"changelog": "Apilo: email z danymi zamówienia + infinite retry co 30 min dla order jobów",
|
||||||
|
"version": "0.342",
|
||||||
|
"files": {
|
||||||
|
"added": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"deleted": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"modified": [
|
||||||
|
"autoload/Domain/CronJob/CronJobRepository.php",
|
||||||
|
"autoload/Domain/CronJob/CronJobType.php",
|
||||||
|
"cron.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"checksum_zip": "sha256:1c1560ecdb4f83f62fa1c5b6c97f7c1a9640aa9b6c4927ad29acc96ff23d8ecd",
|
||||||
|
"sql": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"date": "2026-03-19",
|
||||||
|
"directories_deleted": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
updates/0.30/ver_0.343.zip
Normal file
BIN
updates/0.30/ver_0.343.zip
Normal file
Binary file not shown.
24
updates/0.30/ver_0.343_manifest.json
Normal file
24
updates/0.30/ver_0.343_manifest.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"changelog": "Custom fields: type + is_required + obsługa obrazków w koszyku",
|
||||||
|
"version": "0.343",
|
||||||
|
"files": {
|
||||||
|
"added": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"deleted": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"modified": [
|
||||||
|
"autoload/Domain/Product/ProductRepository.php",
|
||||||
|
"templates/shop-basket/_partials/product-custom-fields.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"checksum_zip": "sha256:bd3b968a4b389c0c3fd00a511e5a3ef0405d4b60079d6b460335f93b8faa92d2",
|
||||||
|
"sql": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"date": "2026-03-19",
|
||||||
|
"directories_deleted": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
updates/0.30/ver_0.344.zip
Normal file
BIN
updates/0.30/ver_0.344.zip
Normal file
Binary file not shown.
26
updates/0.30/ver_0.344_manifest.json
Normal file
26
updates/0.30/ver_0.344_manifest.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"changelog": "Edycja personalizacji produktu w koszyku",
|
||||||
|
"version": "0.344",
|
||||||
|
"files": {
|
||||||
|
"added": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"deleted": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"modified": [
|
||||||
|
"autoload/front/Controllers/ShopBasketController.php",
|
||||||
|
"templates/shop-basket/_partials/product-custom-fields.php",
|
||||||
|
"templates/shop-basket/basket-details.php",
|
||||||
|
"templates/shop-basket/basket.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"checksum_zip": "sha256:5d48acd5be4c2674cf8f0288e13b7dcad6ea9645aaa68c1d6af49e64b417d36f",
|
||||||
|
"sql": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"date": "2026-03-19",
|
||||||
|
"directories_deleted": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
updates/0.30/ver_0.345.zip
Normal file
BIN
updates/0.30/ver_0.345.zip
Normal file
Binary file not shown.
27
updates/0.30/ver_0.345_manifest.json
Normal file
27
updates/0.30/ver_0.345_manifest.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"changelog": "Checkout flow fix - summaryView redirect, TTL token 30min, logowanie bledow zamowien",
|
||||||
|
"version": "0.345",
|
||||||
|
"files": {
|
||||||
|
"added": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"deleted": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"modified": [
|
||||||
|
"autoload/front/Controllers/ShopBasketController.php",
|
||||||
|
"templates/shop-basket/basket.php",
|
||||||
|
"templates/shop-basket/summary-view.php",
|
||||||
|
"templates/shop-order/order-details.php",
|
||||||
|
"templates/shop-product/product.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"checksum_zip": "sha256:805e4d80fe75679c937974059594984377a81cad84a1308d9deefb96e0b39319",
|
||||||
|
"sql": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"date": "2026-03-25",
|
||||||
|
"directories_deleted": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,3 +1,18 @@
|
|||||||
|
<b>ver. 0.345 - 25.03.2026</b><br />
|
||||||
|
Checkout flow fix - summaryView redirect, TTL token 30min, logowanie bledow zamowien
|
||||||
|
<hr>
|
||||||
|
<b>ver. 0.344 - 19.03.2026</b><br />
|
||||||
|
Edycja personalizacji produktu w koszyku
|
||||||
|
<hr>
|
||||||
|
<b>ver. 0.343 - 19.03.2026</b><br />
|
||||||
|
Custom fields: type + is_required + obsługa obrazków w koszyku
|
||||||
|
<hr>
|
||||||
|
<b>ver. 0.342 - 19.03.2026</b><br />
|
||||||
|
Apilo: email z danymi zamówienia + infinite retry co 30 min dla order jobów
|
||||||
|
<hr>
|
||||||
|
<b>ver. 0.341 - 16.03.2026</b><br />
|
||||||
|
Bugfix: naprawiono wysyłkę zamówień do Apilo (regresja z 0.339), retry failed orders co 1h, powiadomienia mailowe o błędach
|
||||||
|
<hr>
|
||||||
<b>ver. 0.341 - 16.03.2026</b><br />
|
<b>ver. 0.341 - 16.03.2026</b><br />
|
||||||
FIX - cron.php — dodano brakujące $apiloRepository do klauzul use() w 5 handlerach cron (APILO_TOKEN_KEEPALIVE, APILO_SEND_ORDER, APILO_PRODUCT_SYNC, APILO_PRICELIST_SYNC, APILO_STATUS_POLL); regresja z ver. 0.339 (split IntegrationsRepository → ApiloRepository) powodowała Call to a member function apiloGetAccessToken() on null
|
FIX - cron.php — dodano brakujące $apiloRepository do klauzul use() w 5 handlerach cron (APILO_TOKEN_KEEPALIVE, APILO_SEND_ORDER, APILO_PRODUCT_SYNC, APILO_PRICELIST_SYNC, APILO_STATUS_POLL); regresja z ver. 0.339 (split IntegrationsRepository → ApiloRepository) powodowała Call to a member function apiloGetAccessToken() on null
|
||||||
FIX - cron.php — zamówienia z apilo_order_id = -1 (failed) są teraz automatycznie ponawiane co 1h zamiast trwale pomijane; priorytet: najpierw nowe zamówienia (NULL), potem retry (-1)
|
FIX - cron.php — zamówienia z apilo_order_id = -1 (failed) są teraz automatycznie ponawiane co 1h zamiast trwale pomijane; priorytet: najpierw nowe zamówienia (NULL), potem retry (-1)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?
|
<?
|
||||||
$current_ver = 341;
|
$current_ver = 345;
|
||||||
|
|
||||||
for ($i = 1; $i <= $current_ver; $i++)
|
for ($i = 1; $i <= $current_ver; $i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user