| Field | Description | Example |
|---|---|---|
id | ||
name | The given name for the discount | |
handle | The unique handle for the discount | |
type | The type of discount | Lunar\DiscountTypes\BuyXGetY |
data | JSON | Any data to be used by the type class |
starts_at | The datetime the discount starts (required) | |
ends_at | The datetime the discount expires, if NULL it won’t expire | |
uses | How many uses the discount has had | |
max_uses | The maximum times this discount can be applied storewide | |
priority | The order of priority | |
stop | Whether this discount will stop others after propagating | |
created_at | ||
updated_at |
Creating a discount
Fetching a discount
The following scopes are available:Resetting the discount cache
For performance reasons the applicable discounts are cached per request. If you need to reset this cache (for example after adding a discount code) you should callresetDiscounts():
Discount Purchasable
You can relate a purchasable to a discount via this model. Each has a type for whether it’s acondition or reward.
condition- If your discount requires these purchasable models to be in the cart to activatereward- Once the conditions are met, discount one of more of these purchasable models.
| Field | Description | Example |
|---|---|---|
id | ||
discount_id | ||
purchasable_type | product_variant | |
type | condition or reward | |
created_at | ||
updated_at |
Relationships
- Purchasables
discount_purchasables - Users -
customer_user