Documentation ¶
Overview ¶
Package coupon is a default implementation of discount interface declared in "github.com/ottemo/commerce/app/models/checkout" package
Index ¶
- Constants
- func Apply(context api.InterfaceApplicationContext) (interface{}, error)
- func Create(context api.InterfaceApplicationContext) (interface{}, error)
- func DeleteByID(context api.InterfaceApplicationContext) (interface{}, error)
- func DownloadCSV(context api.InterfaceApplicationContext) (interface{}, error)
- func GetByID(context api.InterfaceApplicationContext) (interface{}, error)
- func List(context api.InterfaceApplicationContext) (interface{}, error)
- func Remove(context api.InterfaceApplicationContext) (interface{}, error)
- func UpdateByID(context api.InterfaceApplicationContext) (interface{}, error)
- func UploadCSV(context api.InterfaceApplicationContext) (interface{}, error)
- type Coupon
Constants ¶
const ( ConstSessionKeyCurrentRedemptions = "current_redemption_codes" ConstCollectionNameCouponDiscounts = "coupon_discounts" ConstConfigPathDiscounts = "general.discounts" ConstConfigPathDiscountApplyPriority = "general.discounts.discount_apply_priority" ConstErrorModule = "coupon" ConstErrorLevel = env.ConstErrorLevelActor )
Package global constants
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply(context api.InterfaceApplicationContext) (interface{}, error)
Apply will add the coupon code to the current checkout
- coupon code should be specified in "coupon" argument
func Create ¶
func Create(context api.InterfaceApplicationContext) (interface{}, error)
Create will generate a new coupon code when supplied the following required keys, they are not required to match.
- "name" is the desired reference key for the coupon
- "code" is the text visitors must enter to apply a coupon in checkout
func DeleteByID ¶
func DeleteByID(context api.InterfaceApplicationContext) (interface{}, error)
DeleteByID deletes specified SEO item
- discount id should be specified in the "couponID" argument
func DownloadCSV ¶
func DownloadCSV(context api.InterfaceApplicationContext) (interface{}, error)
DownloadCSV returns a csv file with the current coupons and their configuration
- returns a csv file
func GetByID ¶
func GetByID(context api.InterfaceApplicationContext) (interface{}, error)
GetByID returns a coupon with the specified ID * coupon id should be specified in the "id" argument
func List ¶
func List(context api.InterfaceApplicationContext) (interface{}, error)
List returns a list registered coupons and is an protected resource that requires authentication to access.
func Remove ¶
func Remove(context api.InterfaceApplicationContext) (interface{}, error)
Remove will remove the coupon code and its value from the current checkout
- "coupon" key refers to the coupon code
- use a "*" as the coupon code to revert all discounts
func UpdateByID ¶
func UpdateByID(context api.InterfaceApplicationContext) (interface{}, error)
UpdateByID updates existing coupon specified in the request argument
- coupon id should be specified in "couponID" argument
func UploadCSV ¶
func UploadCSV(context api.InterfaceApplicationContext) (interface{}, error)
UploadCSV will overwrite and replace the current coupon configuration with the uploaded CSV
NOTE: the csv file should be provided in a "file" field when sent as a multipart form
Types ¶
type Coupon ¶
type Coupon struct{}
Coupon is a default implementer of InterfaceDiscount
func (*Coupon) Calculate ¶
func (it *Coupon) Calculate(checkoutInstance checkout.InterfaceCheckout, currentPriority float64) []checkout.StructPriceAdjustment
Calculate calculates and returns a set of coupons applied to the provided checkout
func (*Coupon) GetPriority ¶
GetPriority returns the code of the current coupon implementation