OrderDiscount
Use this component to apply discounts scheduled in the Campaign Manager module in Commerce Server Business Desk to the shopping basket.
Intended use: Order Processing pipeline, Order Adjust Price stage.
Configuration Values
None.
Values Read
The OrderDiscount component reads the following values from the indicated dictionaries.
Key | Dictionary | Description |
item._cy_iadjust_currentprice |
Order | The current price of an item. May have been adjusted in the Item Adjust Price stage. |
item.quantity |
Order | The total quantity of an item. |
item._cy_oadjust_adjustedprice |
Order | Optional. The total cost of the item before discounts. |
item._n_unadjusted |
Order | Optional. The quantity of this item that have not been discounted. |
item._product_* |
Order | The product properties for each item. The column name is appended to form the key name. For more information, see the Remarkssection. |
item.discounts_applied |
Order | Optional. A dictionary containing the IDs of the discounts that applied to this item. Keys are the IDs; values are the date-time stamps of the discounts. |
currency_decimal_places |
Order | Optional. The number of the decimal places in the current currency. The default is two (2). |
discounts_clicked |
Order | Optional. The campaign item IDs of the click-required discounts that have been clicked. |
Evaluator |
Context | A reference to an ExpressionEval object. |
CacheManager |
Context | A reference to the CacheManager object to use for retrieving the discount schedule. |
CacheName |
Context | String. The name of the cache. |
MessageManager |
Context | A reference to a MessageManager object that uses the discount removed error constant (pur _discount _removed ) and the discount changed error constant (pur _discount _changed ) to retrieve error messages. |
Language |
Context | Optional. The language for messages used by the MessageManager object. |
UserProfile |
Context | Optional. A reference to a user profile object. |
ContextProfile |
Context | Optional. A reference to an ExprEvalContext (expression context profile) object for use with the expression evaluator. |
SiteName |
Context | Optional. The site name, used in error messages. |
Values Written
The OrderDiscount component writes the following values to the Order dictionary.
Key | Description |
_discounts |
A ContentList object containing the schedule of discounts. For the structure of the ContentList object, see CSFLoadDiscounts. |
_winners |
This key contains the campaign item IDs of all discounts applied to the basket. |
_event |
This key contains the name of the event to record, which should always be set to SOLD. This value is used by the RecordEvent and IISAppendToLog components. |
item._cy_oadjust_adjustedprice |
Optional. The total price of the items that have had discounts applied. |
item._n_unadjusted |
Optional. The number of items whose price remains unadjusted after discounts are applied. |
item.discounts_applied |
Optional. A dictionary containing the campaign item IDs of the discounts that applied to this item. The keys are the IDs; the values are the date-time stamps of the discounts. |
_discounts_removed |
Optional. A SimpleList object of campaign item IDs of discounts that no longer apply since the last time the pipeline was run. This key is written only if some discounts no longer apply. |
_discounts_changed |
Optional. A SimpleList object of campaign item IDs of discounts that have changed since the last time the pipeline was run. This key is written only if some discounts have changed. |
_Basket_Errors |
Error messages are written to this SimpleList object. |
_<special_offer_type>_type |
Optional. The type of an order-level discount, if one applies. Another component in the pipeline (such as ShippingDiscountAdjust) applies the discount. The key name is formed from the string stored in the special _offer _type key in the ContentList object. Possible values are:
Free shipping is an example of an order-level discount. |
_cy_<special_offer_type>_value |
Optional. The value of an order-level discount, if one applies. Another component in the pipeline (such as ShippingDiscountAdjust) applies the discount. This key is used only for custom discounts applied outside of the pipeline. The key name is formed from the string stored in the u _special _offer _type key in the discount database. The value of the discount comes from the offer _value field in the ContentList object. Free shipping is an example of an order-level discount. |
_cy_<special_offer_type>_description |
Optional. String. The description of an order-level discount if one applies. This key may be used to display when the discount applies somewhere on the page. The value comes from the description field in the ContentList object. |
Errors
The component writes error messages to the _Basket
_Errors
collection. The component uses a MessageManager object to retrieve user warning message text.
Constant | Condition |
pur_discount_removed |
A discount no longer applies since the pipeline was last run. |
pur_discount_changed |
A discount has changed since the pipeline was last run. |
Remarks
The OrderDiscount component applies discounts to the shopping basket of a user. The discounts are scheduled through the Campaign Manager module in Commerce Server Business Desk. Each discount is a campaign item and has a unique campaign item ID.
You can adjust the scores of discounts that the OrderDiscount component applies by using the ScoreDiscounts component in a Content Selection pipeline. The ScoreDiscounts component adjusts the scores of discounts and saves them in the ContentList object held by the CacheManager object. That ContentList object would then be used by the OrderDiscount component in another pipeline.
The OrderDiscount component rounds at the line item level — if more than one discount applies to a line item, the discounts are combined before rounding is done. Currencies with four decimal places of precision are the exception. In this case, values are truncated to four decimal places as discounts are combined.
For a detailed discussion about how discounts are selected and applied, see Discount Objects.
The _winners
and _event
keys are used to record events for tracking in the campaign system and are imported into the Data Warehouse for reporting.