-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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(medusa): Trim discount code on insert and retrieve #2369
Changes from all commits
480c602
850c532
26f3aca
48176d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@medusajs/medusa": patch | ||
--- | ||
|
||
feat(medusa): Trim discount code on insert and retrieve |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,8 +212,6 @@ class DiscountService extends TransactionBaseService { | |
const discountRule = ruleRepo.create(validatedRule) | ||
const createdDiscountRule = await ruleRepo.save(discountRule) | ||
|
||
discount.code = discount.code!.toUpperCase() | ||
|
||
const created: Discount = discountRepo.create( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: why is this removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry didnt see your comment |
||
discount as DeepPartial<Discount> | ||
) | ||
|
@@ -277,7 +275,7 @@ class DiscountService extends TransactionBaseService { | |
const manager = this.manager_ | ||
const discountRepo = manager.getCustomRepository(this.discountRepository_) | ||
|
||
const normalizedCode = discountCode.toUpperCase() | ||
const normalizedCode = discountCode.toUpperCase().trim() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment: This is in |
||
|
||
let query = buildQuery({ code: normalizedCode, is_dynamic: false }, config) | ||
let discount = await discountRepo.findOne(query) | ||
|
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.
comment: Removed from
create
as we are usingbeforeInsert
in the model