The apply endpoint is used to apply promotions to an order in an e-commerce system. A successful call to this endpoint will;
-
qualify any currently applied promotions in the order to ensure they still apply
-
validate and apply the coupon code sent with the request, if any
-
and apply any automatic promotions that the order qualifies for.
The promotion combination rules that you have configured on your account will decide if and how multiple promotions are applied to an order.
All successfully applied promotions will be returned in the appliedPromotions property of the Order object in the response. This is a combination of successfully applied automatic promotions and any coupon code or promotion that you specified in the request.
You should always pass back the array of applied promotions in the
Orderobject with subsequent requests to theapplyendpoint so that the applied promotions can be checked against the updated cart or order to ensure they still meet the qualification rules of the promotion.
Free items the customer chooses
A free item promotion may offer several products for the customer to pick from. When one is applied we add the first of them to the order at no charge and return all of them on the applied reward, as freeItemPool, so you can present the choice.
Once the customer has picked, call apply again with the top level freeItemSelection. It is for a free item promotion the order is already carrying. You only need to send it when the choice changes: as long as you keep echoing the applied promotion back to us with its appliedReward untouched, the items on its appliedReward.products are granted again. Without appliedReward we cannot tell the promotion has a choice to change: a freeItemSelection aimed at it is refused, and the promotion falls back to its default.
It may accompany a code: applying one promotion and re-choosing the free item on another are independent. What it cannot do is name the promotion the same call is applying, since that promotion is not applied yet, and a choice we cannot tie to an applied promotion is returned as an error rather than quietly dropped.
Every chosen product must appear in freeItemPool, the total quantity must not exceed the reward's quantity, and no single product may exceed its own maxQuantity. The same item may be chosen more than once. A freeItemSelection that does not hold up costs the customer the choice, not the promotion: the reason comes back in errors and the promotion stays applied on whatever it was granting before.
What the basket already holds is judged differently. If the promotion has been reconfigured since it was applied and the items on its appliedReward.products are no longer something it can grant, the promotion no longer qualifies and is not applied again -- the same answer a product bundle gives when its configuration moves. Apply the code again to be offered the new freeItemPool. An automatic promotion is exempt, because it is re-evaluated from scratch on every call rather than carried.
The free items we add come back in order.products at a price of 0 and marked with freeItem. Send that marker back on them and we will replace those lines on the next call rather than adding another copy of them. A line sent without the marker is treated as the customer's own and kept, so leaving it out means the free item is granted again on top.
See the guide on Reward Application for more information.
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
