Skip to content

Commit

Permalink
docs(core): Minor correction and addition (#3251)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschipperheyn authored Dec 17, 2024
1 parent d606d7a commit af59b36
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/docs/guides/core-concepts/promotions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ For example, if we want to set up a "buy 1, get 1 free" offer, we need to:

In this scenario, we would have to repeat the logic for checking the Order contents in _both_ the PromotionCondition _and_ the PromotionAction. Not only is this duplicated work for the server, it also means that setting up the promotion relies on the same parameters being input into the PromotionCondition and the PromotionAction.

Note the use of `PromotionItemAction` to get a reference to the `OrderLine` as opposed to the `Order`.

Instead, we can say that the PromotionAction _depends_ on the PromotionCondition:

```ts
Expand All @@ -280,7 +282,7 @@ export const buy1Get1FreeAction = new PromotionItemAction({
args: {},
// highlight-next-line
conditions: [buyXGetYFreeCondition],
execute(ctx, orderItem, orderLine, args, state) {
execute(ctx, orderLine, args, state) {
// highlight-next-line
const freeItemIds = state.buy_x_get_y_free.freeItemIds;
if (idsContainsItem(freeItemIds, orderItem)) {
Expand Down

0 comments on commit af59b36

Please sign in to comment.