Class DiscountPlan
DiscountPlan represents a set of Discounts. Instances of the class are returned by the PromotionMgr when requesting applicable discounts for a specified set of promotions and a line item container (see PromotionMgr.getDiscounts(LineItemCtnr, PromotionPlan)).
DiscountPlan provides methods to access the discounts contained in the plan, add additional discounts to the plan (future) or remove discounts from the plan.
See Also:
| Property | Description |
|---|---|
approachingOrderDiscounts: Collection (read-only) | Get the collection of order discounts that the LineItemCtnr "almost" qualifies for based on the merchandise total in the cart. |
bonusDiscounts: Collection (read-only) | Returns all bonus discounts contained in the discount plan. |
lineItemCtnr: LineItemCtnr (read-only) | Returns line item container associated with discount plan. |
orderDiscounts: Collection (read-only) | Returns the percentage and amount order discounts contained in the discount plan. |
This class does not have a constructor, so you cannot create it directly.
| Method | Description |
|---|---|
| getApproachingOrderDiscounts() | Get the collection of order discounts that the LineItemCtnr "almost" qualifies for based on the merchandise total in the cart. |
| getApproachingShippingDiscounts(Shipment) | Get the collection of shipping discounts that the passed shipment "almost" qualifies for based on the merchandise total in the shipment. |
| getApproachingShippingDiscounts(Shipment, ShippingMethod) | Get the collection of shipping discounts that the passed shipment "almost" qualifies for based on the merchandise total in the shipment. |
| getApproachingShippingDiscounts(Shipment, Collection) | Get the collection of shipping discounts that the passed shipment "almost" qualifies for based on the merchandise total in the shipment. |
| getBonusDiscounts() | Returns all bonus discounts contained in the discount plan. |
| getLineItemCtnr() | Returns line item container associated with discount plan. |
| getOrderDiscounts() | Returns the percentage and amount order discounts contained in the discount plan. |
| getProductDiscounts(ProductLineItem) | Returns the percentage, amount and fix price discounts associated with the specified product line item. |
| getProductShippingDiscounts(ProductLineItem) | Returns the product-shipping discounts associated with the specified product line item. |
| getShippingDiscounts(Shipment) | Returns the percentage, amount and fix price discounts associated with the specified shipment. |
| removeDiscount(Discount) | Removes the specified discount from the discount plan. |
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
- approachingOrderDiscounts: Collection
(read-only) Get the collection of order discounts that the LineItemCtnr "almost" qualifies for based on the merchandise total in the cart. Nearness is controlled by thresholds configured at the promotion level.
The collection of returned approaching discounts is ordered by the condition threshold of the promotion (e.g. "spend $100 and get 10% off" discount is returned before "spend $150 and get 15% off" discount.) A discount is not returned if it would be prevented from applying (because of compatibility rules) by an order discount already in the DiscountPlan or an approaching order discount with a lower condition threshold.
- bonusDiscounts: Collection
(read-only) Returns all bonus discounts contained in the discount plan.
- lineItemCtnr: LineItemCtnr
(read-only) Returns line item container associated with discount plan.
A discount plan is created from and associated with a line item container. This method returns the line item container associated with this discount plan.
- orderDiscounts: Collection
(read-only) Returns the percentage and amount order discounts contained in the discount plan.
- getApproachingOrderDiscounts(): Collection
Get the collection of order discounts that the LineItemCtnr "almost" qualifies for based on the merchandise total in the cart. Nearness is controlled by thresholds configured at the promotion level.
The collection of returned approaching discounts is ordered by the condition threshold of the promotion (e.g. "spend $100 and get 10% off" discount is returned before "spend $150 and get 15% off" discount.) A discount is not returned if it would be prevented from applying (because of compatibility rules) by an order discount already in the DiscountPlan or an approaching order discount with a lower condition threshold.
Returns:
- Collection of approaching order discounts ordered by the condition threshold of the promotion ascending.
- getApproachingShippingDiscounts(shipment: Shipment): Collection
Get the collection of shipping discounts that the passed shipment "almost" qualifies for based on the merchandise total in the shipment. Nearness is controlled by thresholds configured at the promotion level.
The collection of returned approaching discounts is ordered by the condition threshold of the promotion (e.g. "spend $100 and get free standard shipping" discount is returned before "spend $150 and get free standard shipping" discount.) A discount is not returned if it would be prevented from applying (because of compatibility rules) by a shipping discount already in the DiscountPlan or an approaching shipping discount with a lower condition threshold.
Parameters:
- shipment - The shipment to calculate approaching discounts for.
Returns:
- Collection of approaching shipping discounts ordered by the condition threshold of the promotion ascending.
- getApproachingShippingDiscounts(shipment: Shipment, shippingMethod: ShippingMethod): Collection
Get the collection of shipping discounts that the passed shipment "almost" qualifies for based on the merchandise total in the shipment. Here "almost" is controlled by thresholds configured at the promotion level.
This method only returns discounts for shipping promotions which apply to the passed shipping method.
The collection of returned approaching discounts is ordered by the condition threshold of the promotion (e.g. "spend $100 and get free standard shipping" discount is returned before "spend $150 and get free standard shipping" discount.) A discount is not returned if it would be prevented from applying (because of compatibility rules) by a shipping discount already in the DiscountPlan or an approaching shipping discount with a lower condition threshold.
Parameters:
- shipment - The shipment to calculate approaching discounts for.
- shippingMethod - The shipping method to filter by.
Returns:
- Collection of approaching shipping discounts ordered by the condition threshold of the promotion, ascending.
- getApproachingShippingDiscounts(shipment: Shipment, shippingMethods: Collection): Collection
Get the collection of shipping discounts that the passed shipment "almost" qualifies for based on the merchandise total in the shipment. Here "almost" is controlled by thresholds configured at the promotion level.
This method only returns discounts for shipping promotions which apply to one of the passed shipping methods.
The collection of returned approaching discounts is ordered by the condition threshold of the promotion (e.g. "spend $100 and get free standard shipping" discount is returned before "spend $150 and get free standard shipping" discount.) A discount is not returned if it would be prevented from applying (because of compatibility rules) by a shipping discount already in the DiscountPlan or an approaching shipping discount with a lower condition threshold.
Parameters:
- shipment - The shipment to calculate approaching discounts for.
- shippingMethods - The shipping methods to filter by.
Returns:
- Collection of approaching shipping discounts ordered by the condition threshold of the promotion ascending.
- getBonusDiscounts(): Collection
Returns all bonus discounts contained in the discount plan.
Returns:
- All bonus discounts contained in discount plan
- getLineItemCtnr(): LineItemCtnr
Returns line item container associated with discount plan.
A discount plan is created from and associated with a line item container. This method returns the line item container associated with this discount plan.
Returns:
- Line item container associated with plan
- getOrderDiscounts(): Collection
Returns the percentage and amount order discounts contained in the discount plan.
Returns:
- Order discounts contained in the discount plan
- getProductDiscounts(productLineItem: ProductLineItem): Collection
Returns the percentage, amount and fix price discounts associated with the specified product line item. If the specified product line item is not contained in the discount plan, an empty collection is returned.
Parameters:
- productLineItem - Product line item
Returns:
- Discounts associated with specified product line item
- getProductShippingDiscounts(productLineItem: ProductLineItem): Collection
Returns the product-shipping discounts associated with the specified product line item. If the specified product line item is not contained in the discount plan, an empty collection is returned.
Parameters:
- productLineItem - Product line item
Returns:
- Product-shipping discounts associated with specified product line item
- getShippingDiscounts(shipment: Shipment): Collection
Returns the percentage, amount and fix price discounts associated with the specified shipment. If the specified shipment is not contained in the discount plan, an empty collection is returned.
Parameters:
- shipment - the shipment for which to fetch discounts.
Returns:
- Discounts associated with specified shipment
- removeDiscount(discount: Discount): void
Removes the specified discount from the discount plan.
This method should only be used for very simple discount scenarios. It is not recommended to use the method in case of stacked discounts (i.e. multiple order or product discounts), or complex discount types like Buy X Get Y or Total Fixed Price, since correct re-calculation of the discount plan based on the promotion rules is not guaranteed.
Parameters:
- discount - Discount to be removed