fix(medusa-plugin-sendgrid): Undefined order in method to build GiftCard data (#3238)
This commit is contained in:
1 parent
f0ab7fda80
commit
8194d19b0e
2 files changed
+22
-15
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"medusa-plugin-sendgrid": patch
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa-plugin-sendgrid): Undefined order
|
||||||
@@ -582,15 +582,23 @@ class SendGridService extends NotificationService {
|
|||||||
relations: ["region", "order"],
|
relations: ["region", "order"],
|
||||||
})
|
})
|
||||||
const taxRate = giftCard.region.tax_rate / 100
|
const taxRate = giftCard.region.tax_rate / 100
|
||||||
const locale = giftCard.order ? await this.extractLocale(order) : null;
|
const locale = giftCard.order
|
||||||
const email = giftCard.order ? giftCard.order.email : giftCard.metadata.email;
|
? await this.extractLocale(giftCard.order)
|
||||||
|
: null
|
||||||
|
const email = giftCard.order
|
||||||
|
? giftCard.order.email
|
||||||
|
: giftCard.metadata.email
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...giftCard,
|
...giftCard,
|
||||||
locale,
|
locale,
|
||||||
email,
|
email,
|
||||||
display_value: `${this.humanPrice_((giftCard.value * 1+ taxRate), giftCard.region.currency_code)} ${giftCard.region.currency_code}`,
|
display_value: `${this.humanPrice_(
|
||||||
message: giftCard.metadata?.message || giftCard.metadata?.personal_message
|
giftCard.value * 1 + taxRate,
|
||||||
|
giftCard.region.currency_code
|
||||||
|
)} ${giftCard.region.currency_code}`,
|
||||||
|
message:
|
||||||
|
giftCard.metadata?.message || giftCard.metadata?.personal_message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1161,13 +1169,7 @@ class SendGridService extends NotificationService {
|
|||||||
|
|
||||||
async orderRefundCreatedData({ id, refund_id }) {
|
async orderRefundCreatedData({ id, refund_id }) {
|
||||||
const order = await this.orderService_.retrieveWithTotals(id, {
|
const order = await this.orderService_.retrieveWithTotals(id, {
|
||||||
select: [
|
relations: ["refunds", "items"],
|
||||||
"total",
|
|
||||||
],
|
|
||||||
relations: [
|
|
||||||
"refunds",
|
|
||||||
"items",
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const refund = order.refunds.find((refund) => refund.id === refund_id)
|
const refund = order.refunds.find((refund) => refund.id === refund_id)
|
||||||
@@ -1175,11 +1177,10 @@ class SendGridService extends NotificationService {
|
|||||||
return {
|
return {
|
||||||
order,
|
order,
|
||||||
refund,
|
refund,
|
||||||
refund_amount: `${this.humanPrice_(
|
refund_amount: `${this.humanPrice_(refund.amount, order.currency_code)} ${
|
||||||
refund.amount,
|
|
||||||
order.currency_code
|
order.currency_code
|
||||||
)} ${order.currency_code}`,
|
}`,
|
||||||
email: order.email
|
email: order.email,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user