promotions
Build and Publish / BuildAndDeployArm64 (push) Failing after 6s
Build and Publish / BuildAndDeployAmd64 (push) Has been cancelled

This commit is contained in:
2026-06-18 11:32:19 +02:00
parent 2545be4315
commit 2443fd8b49
9 changed files with 583 additions and 55 deletions
+10 -2
View File
@@ -149,8 +149,11 @@ func main() {
// any matched actions (e.g. the Volymrabatt volume discount), which adjust
// TotalPrice/TotalDiscount on top of line items and vouchers.
promotionCtx := promotions.NewContextFromCart(g, promotions.WithNow(time.Now()))
_, actions := promotionService.EvaluateAll(promotionStore.Snapshot(), promotionCtx)
promotions.ApplyActions(g, actions)
results, _ := promotionService.EvaluateAll(promotionStore.Snapshot(), promotionCtx)
// ApplyResults applies qualifying actions in priority order and records
// every effect — both applied discounts and pending "spend X more for ..."
// nudges with their progress — in g.AppliedPromotions.
promotionService.ApplyResults(g, results, promotionCtx)
g.Version++
return nil
}),
@@ -275,6 +278,11 @@ func main() {
mux.Handle("/mcp", promotionMCP.Handler())
mux.Handle("/mcp/", promotionMCP.Handler())
// Stateless promotion evaluation: POST a (possibly partial) eval context and
// get back the resulting totals plus the applied/pending effect breakdown,
// without creating or mutating a real cart.
mux.HandleFunc("POST /promotions/evaluate", newPromotionEvaluateHandler(promotionStore, promotionService))
// only for local
mux.HandleFunc("GET /add/remote/{host}", func(w http.ResponseWriter, r *http.Request) {
pool.AddRemote(r.PathValue("host"))