Documentation
¶
Index ¶
- Constants
- Variables
- func Query(db *datastore.Datastore) datastore.Query
- type Coupon
- func (c Coupon) Code() string
- func (c *Coupon) CodeFromId(uniqueid string) string
- func (c *Coupon) Defaults()
- func (c Coupon) DynamicCode() string
- func (c *Coupon) Init(db *datastore.Datastore)
- func (c Coupon) ItemId() string
- func (c Coupon) Kind() string
- func (co *Coupon) Load(ps []datastore.Property) (err error)
- func (c *Coupon) Redeemable() bool
- func (c *Coupon) Redemptions() int
- func (co *Coupon) Save() (ps []datastore.Property, err error)
- func (c *Coupon) SaveRedemption() error
- func (c Coupon) ValidFor(t time.Time) bool
- type Redemption
- type Type
Constants ¶
View Source
const ( Flat Type = "flat" Percent = "percent" FreeShipping = "free-shipping" FreeItem = "free-item" )
Variables ¶
View Source
var Types = []Type{Flat, Percent, FreeShipping}
Functions ¶
Types ¶
type Coupon ¶
type Coupon struct {
mixin.Model
Name string `json:"name"`
// Possible values: flat, percent, free_shipping.
Type Type `json:"type"`
// Coupon code (must be unique).
Code_ string `json:"code" datastore:"Code"`
RawCode string `json:"-" datastore:"-"`
// Indicates whether or not the Code is dynamically checked (for something like user-generated coupons)
Dynamic bool `json:"dynamic"`
CampaignId string `json:"campaignId,omitempty"`
ReferrerId string `json:"referrerId,omitempty"`
// Range in which coupon is valid
StartDate time.Time `json:"startDate"`
EndDate time.Time `json:"endDate"`
// Possible values: order, product.
Filter string `json:"filter"`
// Indicates whether this coupon may be applied once or more than once at checkout.
Once bool `json:"once"`
// The number of times this coupon can be used before it is used up and useless. 0 = unlimited
Limit int `json:"limit"`
// Product id for product-specific coupons.
ProductId string `json:"productId,omitempty"`
// Whether coupon is valid.
Enabled bool `json:"enabled"`
// Coupon amount. $5 should be 500 (prices in basic currency unit, like cents). 10% should be 10.
// TODO: This needs to be currency.Cents in Hanzo.
Amount int `json:"amount"`
// Number of times coupon was redeemed.
Used int `json:"used"`
// Free product with coupon
FreeProductId string `json:"freeProductId"`
FreeVariantId string `json:"freeVariantId"`
FreeQuantity int `json:"freeQuantity"`
}
func (*Coupon) CodeFromId ¶
func (Coupon) DynamicCode ¶
func (*Coupon) Redeemable ¶
func (*Coupon) Redemptions ¶
func (*Coupon) SaveRedemption ¶
type Redemption ¶
Click to show internal directories.
Click to hide internal directories.