update
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 35s
Build and Publish / BuildAndDeployArm64 (push) Successful in 3m45s

This commit is contained in:
matst80
2025-11-27 12:45:34 +01:00
parent c2a137d8d4
commit aea168160e
14 changed files with 335 additions and 335 deletions

View File

@@ -1,7 +1,10 @@
package cart
import (
"context"
"fmt"
"log"
"time"
messages "git.k6n.net/go-cart-actor/pkg/messages"
)
@@ -39,6 +42,14 @@ func (c *CartMutationContext) RemoveItem(g *CartGrain, m *messages.RemoveItem) e
return fmt.Errorf("RemoveItem: item id %d not found", m.Id)
}
item := g.Items[index]
if item.ReservationEndTime != nil && item.ReservationEndTime.After(time.Now()) {
err := c.ReleaseItem(context.Background(), g.Id, item.Sku, item.StoreId)
if err != nil {
log.Printf("unable to release item reservation")
}
}
g.Items = append(g.Items[:index], g.Items[index+1:]...)
g.UpdateTotals()
return nil