draftorderitem

package
v1.49.45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 4 Imported by: 0

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

func Query

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 (*DraftOrderItem) Load

func (i *DraftOrderItem) Load(ps []datastore.Property) error

func (*DraftOrderItem) Save

func (i *DraftOrderItem) Save() ([]datastore.Property, error)

func (*DraftOrderItem) TotalCents

func (i *DraftOrderItem) TotalCents() currency.Cents

TotalCents is the extended price of this line: unit price × quantity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL