Files
go-cart-actor/pkg/cart/mutation_clear_cart.go
T
mats 11be8aec56
Build and Publish / BuildAndDeployArm64 (push) Failing after 1m8s
Build and Publish / BuildAndDeployAmd64 (push) Has been cancelled
name
2026-06-17 00:09:30 +02:00

27 lines
593 B
Go

package cart
import (
"fmt"
messages "git.k6n.net/mats/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
}