Documentation
¶
Overview ¶
Package draftorderitem is one line of a draft order (Medusa v2 parity: admin/draft-orders items). Each item is an immutable-shaped fact — a product/variant reference, a quantity, and a server-authoritative unit price — keyed to its parent by DraftOrderId. The draft's total is the projection Σ(unitPrice × qty) over these rows (see draftorder.TotalCents), so adding or removing a line never races a mutable order-total counter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DraftOrderItem ¶
type DraftOrderItem struct {
mixin.Model[DraftOrderItem]
// DraftOrderId is the parent draft this line belongs to.
DraftOrderId string `json:"draftOrderId"`
ProductId string `json:"productId,omitempty"`
ProductName string `json:"productName,omitempty"`
VariantId string `json:"variantId,omitempty"`
VariantName string `json:"variantName,omitempty"`
Quantity int `json:"quantity"`
UnitPriceCents currency.Cents `json:"unitPriceCents"`
Currency currency.Type `json:"currency" orm:"default:usd"`
}
DraftOrderItem is a single line of a draft order. It references either a variant (VariantId) or a bare product (ProductId); the cached name is stored for display. UnitPriceCents is the price the admin set for this line — it is server-authoritative and carried verbatim onto the real order line when the draft is completed.
func New ¶
func New(db *datastore.Datastore) *DraftOrderItem
func (*DraftOrderItem) TotalCents ¶
func (i *DraftOrderItem) TotalCents() currency.Cents
TotalCents is the extended price of this line: unit price × quantity.