price ratio = (unadjusted price of the item / total price of qualifier and target items before offer adjustment) proportionally distributed discount = price ratio * total discount refund amount = item unadjusted price - distributed discount.
After the order has been placed, the offer details and the adjustments for applied offers are populated from the corresponding entities in Cart to Order, OrderItems, OrderFulfillments, and/or OrderFulfillmentItems, depending on the offer types. See Offer Adjustment Mappings for more details.
Note
|
For the structure of offer details and adjustments, please see Understanding Offers Applied to the Cart |
Each offer adjustment, regardless of the offer type, has the same payload as the one for the entities in Cart described in Understanding Offers Applied to the Cart, except for one key difference: the qualifier detail’s itemId
is referencing the id of the OrderItems or OrderFulfillmentItems instead of CartItems or FulfillmentItems.
The adjustment is populated to different entities in Order, based on the corresponding entities:
Cart#adjustments
> Order#adjustments
CartItem#itemAdjustments
> OrderItem#itemAdjustments
FulfillmentGroup#adjustments
> OrderFulfillment#adjustments
FulfillmentItem#fulfillmentAdjustments
> OrderFulfillmentItem#fulfillmentAdjustments
In OrderOperationServices, the offer qualifier and target details are utilized in various different places:
As the Order is being generated from Cart, the merchandise refund amount is pre-calculated based on the qualifier and target items.
By default, the refund amount is the unadjusted item price minus the proportionally distributed discount for each item based on their price ratio, using these formulas:
price ratio = (unadjusted price of the item / total price of qualifier and target items before offer adjustment) proportionally distributed discount = price ratio * total discount refund amount = item unadjusted price - distributed discount.
For example, let’s say we have two items in the Order, itemX ($30) and itemY ($10), with Buy 1X Get 1Y offer applied, the merchandise refund amount for itemX would be $22.5 based on the following calculation:
qualifier (itemX) unadjusted total: 30 target (itemY) unadjusted total: 10 unadjusted total: 30 + 10 = 40 total discount (itemY free) = 10 itemX price ratio: 30/40 = 0.75 proportionally distributed discount on itemX for this offer: 0.75 * 10 = 7.5 refund amount for itemX = 30 - 7.5 = 22.5
Important
|
The offer discount distribution is only done for offers that have the proration type of TARGET_AND_QUALIFIER
|
Any custom logic regarding merchandising refund calculation should override DefaultCartOrderGenerationService#precalculateRefundAmounts
.
When changing the status of applied offer’s qualifier items, it is possible to automatically change the status of the target items as well, by overriding DefaultFulfillmentOperationService#processStatusChangeForOfferTargetItems
.
By default, only the status of free gift items is changed automatically along with their qualifier items.
When returning applied offer’s qualifier items, it is possible to automatically return the target items as well, by overriding DefaultReturnGenerationService#processReturnRequestsForOfferTargetItems
.
By default, only free gift items are automatically returned along with their qualifier items.
When confirming the returns of applied offer’s qualifier items, it is possible to automatically confirm the returns of the target items as well, by overriding DefaultReturnOperationService#processConfirmRequestForOfferTargetItems
.
By default, only the returns of free gift items are automatically confirmed along with their qualifier items.