Documentation
¶
Index ¶
- Constants
- Variables
- func Query(db *datastore.Datastore) datastore.Query
- type Listing
- type Listings
- type ShippingRateTable
- type Store
- func (s *Store) AddListing(id string, listing Listing)
- func (s *Store) AfterCreate() error
- func (s *Store) Defaults()
- func (s Store) GetShippingRates() (*shippingrates.ShippingRates, error)
- func (s Store) GetTaxRates() (*taxrates.TaxRates, error)
- func (s *Store) Load(ps []datastore.Property) (err error)
- func (s *Store) Save() (ps []datastore.Property, err error)
- func (s *Store) UpdateFromListing(entity mixin.Entity)
- func (s *Store) Validator() *val.Validator
Constants ¶
const DefaultSlug = "default"
DefaultSlug is the stable slug of the store every org gets on first use. It is safe to reuse across tenants because each org's merchant rows live in its OWN namespaced store (datastore.NewNamespaced), so the slug never collides.
Variables ¶
var ListingFields = reflect.FieldNames(Listing{})
Functions ¶
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 ShippingRateTable ¶
type Store ¶
type Store struct {
mixin.Model[Store]
// 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:"-" orm:"default:{}"`
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 EnsureDefault ¶ added in v1.47.2
EnsureDefault returns the org's default store, creating it on first use. This is the ONE canonical way an org gets its commerce store: idempotent (keyed by the stable DefaultSlug), org-scoped (db MUST be a per-org datastore.NewNamespaced), and carrying NO payment credentials — binding Square/Stripe stays a separate business step. It replaces the long-dead commented-out provisioning in util/provision: a store is lazily provisioned at the first authenticated GET /v1/store/current instead of eagerly at org creation.
func (*Store) AddListing ¶
Add a new listing to the listings map
func (*Store) Defaults ¶
func (s *Store) Defaults()
Defaults sets runtime defaults that cannot be expressed as orm tags.
func (Store) GetShippingRates ¶
func (s Store) GetShippingRates() (*shippingrates.ShippingRates, error)
Return ShippingRates
func (*Store) UpdateFromListing ¶
Update product/variant using listing for said item