store

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListingFields = reflect.FieldNames(Listing{})

Functions

func Query

Types

type Listing

type Listing struct {
	// Not customizable
	ProductId string        `json:"productId,omitempty"`
	Slug      string        `json:"slug,omitempty"`
	VariantId string        `json:"variantId,omitempty"`
	SKU       string        `json:"sku,omitempty"`
	Currency  currency.Type `json:"currency,omitempty"`

	Name *string `json:"name"`

	Headline    *string `json:"headline,omitempty"`
	Excerpt     *string `json:"excerpt,omitempty"`
	Description *string `json:"description,omitempty"`

	// Product Media
	HeaderImage *Media   `json:"headerImage,omitempty"`
	Media       *[]Media `json:"media,omitempty"`

	Sold *int `json:"sold"`

	Price     *currency.Cents `json:"price,omitempty"`
	ListPrice *currency.Cents `json:"listPrice,omitempty"`
	Shipping  *currency.Cents `json:"shipping,omitempty"`
	Taxable   *bool           `json:"taxable,omitempty"`

	WeightUnit *weight.Unit `json:"weightUnit,omitempty"`

	Available    *bool         `json:"available,omitempty"`
	Availability *Availability `json:"availability,omitempty"`

	Hidden *bool `json:"hidden,omitempty"`
}

Everything is a pointer, which allows fields to be nil. This way when we serialize to/from JSON we know what has and has not been set.

type Listings

type Listings map[string]Listing

type ShippingRateTable

type ShippingRateTable map[string]shipping.Rates

type Store

type Store struct {
	mixin.Model

	// Full name of store
	Name string `json:"name"`

	// Unique human readable id for url <slug>.hanzo.aie
	Slug string `json:"slug"`

	// Where this is hosted if not on hanzo.ai
	Domain string `json:"domain"`
	Prefix string `json:"prefix"`

	// Currency for store
	Currency currency.Type `json:"currency"`

	Address  Address   `json:"address,omitempty"`
	TaxNexus []Address `json:"taxNexus,omitempty"`

	// Overrides per item
	Listings  Listings `json:"listings" datastore:"-"`
	Listings_ string   `json:"-" datastore:",noindex"`

	Salesforce struct {
		PriceBookId string `json:"PriceBookId"`
	} `json:"-"`

	Email           string `json:"email,omitempty"`
	Phone           string `json:"phone,omitempty"`
	Timezone        string `json:"timezone,omitempty"`
	ReferralBaseUrl string `json:"referralBaseUrl,omitempty"`

	Mailchimp struct {
		ListId string `json:"listId"`
		APIKey string `json:"apiKey"`
	} `json:"mailchimp,omitempty"`
}

func Fake

func Fake(db *datastore.Datastore) *Store

func New

func New(db *datastore.Datastore) *Store

func (*Store) AddListing

func (s *Store) AddListing(id string, listing Listing)

Add a new listing to the listings map

func (*Store) AfterCreate

func (s *Store) AfterCreate() error

Hooks

func (*Store) Defaults

func (s *Store) Defaults()

func (Store) GetShippingRates

func (s Store) GetShippingRates() (*shippingrates.ShippingRates, error)

Return ShippingRates

func (Store) GetTaxRates

func (s Store) GetTaxRates() (*taxrates.TaxRates, error)

Return TaxRates

func (*Store) Init

func (s *Store) Init(db *datastore.Datastore)

func (Store) Kind

func (s Store) Kind() string

func (*Store) Load

func (s *Store) Load(ps []datastore.Property) (err error)

func (*Store) Save

func (s *Store) Save() (ps []datastore.Property, err error)

func (*Store) UpdateFromListing

func (s *Store) UpdateFromListing(entity mixin.Entity)

Update product/variant using listing for said item

func (*Store) Validator

func (s *Store) Validator() *val.Validator

Jump to

Keyboard shortcuts

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