package cart import ( "fmt" messages "git.k6n.net/go-cart-actor/proto/cart" ) func ClearCart(g *CartGrain, m *messages.ClearCartRequest) error { if m == nil { return fmt.Errorf("ClearCart: nil payload") } if g.CheckoutStatus != nil { return fmt.Errorf("ClearCart: cart is in checkout") } // Clear items, vouchers, etc., but keep userId, etc. g.Items = g.Items[:0] g.Vouchers = g.Vouchers[:0] g.Notifications = g.Notifications[:0] g.OrderReference = "" g.Processing = false // g.InventoryReserved = false maybe should release inventory g.UpdateTotals() return nil }