-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Create PromotionLineAction (#2971)
Closes #2956
- Loading branch information
Showing
7 changed files
with
222 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { DefaultMoneyStrategy } from '@vendure/core'; | ||
|
||
export class TestMoneyStrategy extends DefaultMoneyStrategy { | ||
round(value: number, quantity = 1): number { | ||
return Math.round(value * quantity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/core/src/config/promotion/actions/order-line-fixed-discount-action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { LanguageCode } from '@vendure/common/lib/generated-types'; | ||
|
||
import { PromotionLineAction } from '../promotion-action'; | ||
|
||
export const orderLineFixedDiscount = new PromotionLineAction({ | ||
code: 'order_line_fixed_discount', | ||
args: { | ||
discount: { | ||
type: 'int', | ||
ui: { | ||
component: 'currency-form-input', | ||
}, | ||
}, | ||
}, | ||
execute(ctx, orderLine, args) { | ||
return -args.discount; | ||
}, | ||
description: [{ languageCode: LanguageCode.en, value: 'Discount orderLine by fixed amount' }], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.