cart

package
v1.36.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IgnoreFieldMismatch = datastore.IgnoreFieldMismatch

Functions

func Query

Types

type Cart

type Cart struct {
	mixin.Model[Cart]

	// Store this was sold from (if any)
	StoreId string `json:"storeId,omitempty"`

	// Associated campaign
	CampaignId string `json:"campaignId,omitempty"`

	// Associated Crowdstart user or buyer.
	UserId string `json:"userId,omitempty"`

	// Email of the user or someone else if no user id exists
	Email string `json:"email,omitempty"`

	// Associated order ID, if any
	OrderId string `json:"orderId,omitempty"`

	// Status
	Status Status `json:"status" orm:"default:active"`

	// 3-letter ISO currency code (lowercase).
	Currency currency.Type `json:"currency"`

	// Sum of the line item amounts. Amount in cents.
	LineTotal currency.Cents `json:"lineTotal"`

	// Discount amount applied to the order. Amount in cents.
	Discount currency.Cents `json:"discount"`

	// Sum of line totals less discount. Amount in cents.
	Subtotal currency.Cents `json:"subtotal"`

	// Shipping cost applied. Amount in cents.
	Shipping currency.Cents `json:"shipping"`

	// Sales tax applied. Amount in cents.
	Tax currency.Cents `json:"tax"`

	// Total = subtotal + shipping + taxes + adjustments. Amount in cents.
	Total currency.Cents `json:"total"`

	Company string `json:"company,omitempty"`

	BillingAddress  Address `json:"billingAddress,omitempty"`
	ShippingAddress Address `json:"shippingAddress,omitempty"`

	// Individual line items
	Items  []lineitem.LineItem `json:"items" datastore:"-" orm:"default:[]"`
	Items_ string              `json:"-" datastore:",noindex"`

	Coupons     []coupon.Coupon `json:"coupons,omitempty" datastore:",noindex" orm:"default:[]"`
	CouponCodes []string        `json:"couponCodes,omitempty" datastore:",noindex"`
	ReferrerId  string          `json:"referrerId,omitempty"`

	// Series of events that have occured relevant to this order
	History []Event `json:"-,omitempty" datastore:",noindex"`

	// Arbitrary key/value pairs associated with this order
	Metadata  Map    `json:"metadata" datastore:"-" orm:"default:{}"`
	Metadata_ string `json:"-" datastore:",noindex"`

	Gift        bool   `json:"gift"`                                       // Is this a gift?
	GiftMessage string `json:"giftMessage,omitempty" datastore:",noindex"` // Message to go on gift
	GiftEmail   string `json:"giftEmail,omitempty"`                        // Email for digital gifts

	Mailchimp struct {
		Id          string `json:"id,omitempty" datastore:",noindex"`
		CampaignId  string `json:"campaignId,omitempty"`
		CheckoutUrl string `json:"checkoutUrl,omitempty" datastore:",noindex"`
	} `json:"mailchimp,omitempty"`
}

func Fake

func Fake(db *datastore.Datastore, userId string) *Cart

func New

func New(db *datastore.Datastore) *Cart

func (Cart) Description

func (c Cart) Description() string

func (Cart) DisplayCreatedAt

func (c Cart) DisplayCreatedAt() string

func (Cart) DisplayDiscount

func (c Cart) DisplayDiscount() string

func (Cart) DisplayId

func (c Cart) DisplayId() string

func (Cart) DisplayShipping

func (c Cart) DisplayShipping() string

func (Cart) DisplaySubtotal

func (c Cart) DisplaySubtotal() string

func (Cart) DisplayTax

func (c Cart) DisplayTax() string

func (Cart) DisplayTotal

func (c Cart) DisplayTotal() string

func (Cart) IntId

func (c Cart) IntId() int

func (Cart) ItemsJSON

func (c Cart) ItemsJSON() string

func (*Cart) Load

func (c *Cart) Load(ps []datastore.Property) (err error)

func (*Cart) RemoveItem

func (c *Cart) RemoveItem(id string) (err error)

func (*Cart) Save

func (c *Cart) Save() (ps []datastore.Property, err error)

func (*Cart) SetItem

func (c *Cart) SetItem(db *datastore.Datastore, id string, typ string, quantity int) (err error)

func (*Cart) SetProduct

func (c *Cart) SetProduct(db *datastore.Datastore, id string, quantity int) (err error)

func (*Cart) SetVariant

func (c *Cart) SetVariant(db *datastore.Datastore, id string, quantity int) (err error)

func (*Cart) Validator

func (c *Cart) Validator() *val.Validator

type Document

type Document struct {
	Id_    string
	UserId string

	ProductIds string

	BillingAddressLine1       string
	BillingAddressLine2       string
	BillingAddressCity        string
	BillingAddressState       string
	BillingAddressCountryCode string
	BillingAddressCountry     string
	BillingAddressPostalCode  string

	ShippingAddressLine1       string
	ShippingAddressLine2       string
	ShippingAddressCity        string
	ShippingAddressState       string
	ShippingAddressCountryCode string
	ShippingAddressCountry     string
	ShippingAddressPostalCode  string

	Type string

	CreatedAt time.Time
	UpdatedAt time.Time

	Currency    string
	Total       float64
	CouponCodes string
	ReferrerId  string

	Status            string
	PaymentStatus     string
	FulfillmentStatus string
	Preorder          string
	Confirmed         string
}

func (Document) Id

func (d Document) Id() string

type Status

type Status string
const (
	Active    Status = "active"
	Discarded Status = "discarded"
	Ordered   Status = "ordered"
)

Jump to

Keyboard shortcuts

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