-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: stackability resolution strategy #6823
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
feat: stackability resolution strategy #6823
Conversation
🦋 Changeset detectedLatest commit: c4c69f3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add 2 more promos with discountCalculationMethod = none and null
let copiedCart = _.cloneDeep(cart); | ||
for (const promo of combinationPromotions) { | ||
// eslint-disable-next-line no-await-in-loop | ||
const { affected, temporaryAffected } = await utils.actionHandler(context, copiedCart, promo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the return values affected
& temporaryAffected
will be defined by the actionHandler
funcs of child plugins (ex packages/api-plugin-promotions-discounts/src/discountTypes/order/applyOrderDiscountToCart.js
). I have not reviewed them now and will review while merging feat/promotions.
Meanwhile, I could not find the field temporaryAffected
being returned by any handler. only affected & reason were returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add remaining entries from util folder here?
|
||
// eslint-disable-next-line no-await-in-loop | ||
const result = await actionFn.handler(context, enhancedCart, { promotion, ...action }); | ||
({ affected, temporaryAffected, reason: rejectedReason } = result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned earlier, I could not find the field temporaryAffected
being returned by any handler. May be I missed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if my understanding is correct, thought of verifying with you.
I added few additional promotions (assuming that it is valid to have more than 1+ explicit promos also)
New input:
const promotion1 = {
_id: "promotionId1",
triggerType: "implicit",
discount: 2,
type: "order",
stackability: {
key: "all"
}
};
const promotion1ex = {
_id: "promotionId1ex",
triggerType: "explicit",
discount: 2,
type: "order",
stackability: {
key: "all"
}
};
const promotion2 = {
_id: "promotionId2",
triggerType: "implicit",
discount: 3,
type: "item",
stackability: {
key: "all"
}
};
const promotion2ex = {
_id: "promotionId2ex",
triggerType: "explicit",
discount: 3,
type: "item",
stackability: {
key: "all"
}
};
const promotion3 = {
_id: "promotionId3",
triggerType: "implicit",
discount: 4,
type: "item",
stackability: {
key: "all"
}
};
const promotion3ex = {
_id: "promotionId3ex",
triggerType: "implicit",
discount: 4,
type: "item",
stackability: {
key: "none"
}
};
const promotion4 = {
_id: "promotionId4",
triggerType: "implicit",
discount: 4,
type: "item",
stackability: {
key: "per-type"
}
};
My expected output was :
[
[promotion1, promotion4],
[promotion1, promotion1ex, promotion2, promotion2ex, promotion3],
[promotion3ex]
]
Actual output was :
[
[promotion4],
[promotion1, promotion1ex, promotion2, promotion2ex, promotion3],
[promotion3ex]
]
I was expecting prom1(type=order) could combine with promo4(type=item)
Signed-off-by: vanpho93 <vanpho02@gmail.com>
92dc44f
to
c4c69f3
Compare
Resolves #6820
Impact: major
Type: feature
Issue
Currently we pick promotions randomly.
Solution
Pick the best combination of promotions and let other plugin override this implementation.