-
-
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.
fix(core): Add a return type to the PromotionAction execute method an…
…d write test code for it
- Loading branch information
Showing
5 changed files
with
183 additions
and
44 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
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
import { LanguageCode } from '@vendure/common/lib/generated-types'; | ||
|
||
import { PromotionItemAction } from '../promotion-action'; | ||
|
||
export const orderLineFixedDiscount = new PromotionItemAction({ | ||
code: 'order_line_fixed_discount', | ||
args: { | ||
discount: { | ||
type: 'int', | ||
ui: { | ||
component: 'currency-form-input', | ||
}, | ||
}, | ||
discountMode: { | ||
type: 'string', | ||
ui: { | ||
component: 'select-form-input', | ||
options: [ | ||
{ label: 'Unit', value: 'unit' }, | ||
{ label: 'Line', value: 'line' }, | ||
], | ||
}, | ||
}, | ||
}, | ||
execute(ctx, orderLine, args) { | ||
return { | ||
amount: -args.discount, | ||
discountMode: (args.discountMode as 'unit' | 'line') || 'line', | ||
}; | ||
}, | ||
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
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