Documentation
¶
Index ¶
- Constants
- Variables
- func GetScopedDiscounts(ctx context.Context, sc scope.Type, id string, keyc chan []iface.Key, ...)
- func Query(db *datastore.Datastore) datastore.Query
- type Discount
- func (d *Discount) AfterCreate() error
- func (d *Discount) AfterDelete() error
- func (d *Discount) AfterUpdate(previous *Discount) error
- func (d *Discount) Defaults()
- func (d *Discount) Init(db *datastore.Datastore)
- func (d Discount) Kind() string
- func (d Discount) ScopeId() string
- func (d Discount) ValidFor(t time.Time) bool
- type Rule
- type Scope
- type Target
- type Type
Constants ¶
View Source
const ( Flat Type = "flat" Percent = "percent" FreeShipping = "free-shipping" FreeItem = "free-item" Bulk = "bulk" )
Variables ¶
View Source
var Types = []Type{Flat, Percent, FreeShipping, FreeItem, Bulk}
Functions ¶
func GetScopedDiscounts ¶
Types ¶
type Discount ¶
type Discount struct {
mixin.Model
Name string `json:"name"`
// Type of discount rule
Type Type `json:"type"`
// Date range in which discount is valid
StartDate time.Time `json:"startDate"`
EndDate time.Time `json:"endDate"`
Scope Scope `json:"scope"`
Target Target `json:"target"`
// Rules for this discount
Rules []Rule `json:"rules"`
// Whether discount is enabled.
Enabled bool `json:"enabled"`
}
func (*Discount) AfterCreate ¶
Invalidate cache based on scope
func (*Discount) AfterDelete ¶
func (*Discount) AfterUpdate ¶
type Rule ¶
type Rule struct {
// Condition which triggers this rule
Trigger rule.Trigger `json:"trigger"`
// Action which happens as result of trigger
Action rule.Action `json:"action"`
}
Encompasses a given rule trigger and discount amount
Click to show internal directories.
Click to hide internal directories.