Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(promotion): Minor correction and addition #3251

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading