Files
zeekay 1943f1c093 Hanzo Commerce
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans,
usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0.

Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
2026-09-23 21:52:16 -07:00

32 lines
567 B
Go

package lineitem
import (
"math/rand"
"github.com/hanzoai/commerce/models/product"
"github.com/hanzoai/commerce/models/variant"
)
func Fake(item interface{}) LineItem {
var li LineItem
switch v := item.(type) {
case *product.Product:
li.ProductId = v.Id()
li.ProductName = v.Name
li.ProductSlug = v.Slug
li.Price = v.Price
case *variant.Variant:
li.VariantId = v.Id()
li.VariantName = v.Name
li.VariantSKU = v.SKU
li.Price = v.Price
default:
panic("Unsupported item")
}
li.Quantity = rand.Intn(5) + 1
li.Taxable = false
return li
}