handle limited quantity
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 36s
Build and Publish / BuildAndDeployArm64 (push) Successful in 3m43s

This commit is contained in:
2025-11-26 21:35:40 +01:00
parent a17d5fc570
commit afa79e7b56
3 changed files with 32 additions and 8 deletions

View File

@@ -48,8 +48,15 @@ func ChangeQuantity(g *CartGrain, m *messages.ChangeQuantity) error {
g.UpdateTotals()
return nil
}
g.Items[foundIndex].Quantity = int(m.Quantity)
g.UpdateTotals()
item := g.Items[foundIndex]
if item == nil {
return fmt.Errorf("ChangeQuantity: item id %d not found", m.Id)
}
if item.ReservationEndTime != nil {
return fmt.Errorf("ChangeQuantity: cannot change quantity of reserved item id %d", m.Id)
} else {
item.Quantity = int(m.Quantity)
g.UpdateTotals()
}
return nil
}