fix(medusa-plugin-sendgrid): Inject GiftCardService to eliminate undefined error (#2941)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"medusa-plugin-sendgrid": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa-plugin-sendgrid): Inject GiftCardService to eliminate undefined error
|
||||||
@@ -3608,8 +3608,9 @@ You don’t have to create a template for every type in the reference. You can s
|
|||||||
```json noReport
|
```json noReport
|
||||||
Object {
|
Object {
|
||||||
"code": Any<String>,
|
"code": Any<String>,
|
||||||
"value": 4,
|
"value": 100,
|
||||||
"balance": 100,
|
"balance": 100,
|
||||||
|
"display_value": "100.00",
|
||||||
"region": Object {
|
"region": Object {
|
||||||
"automatic_taxes": true,
|
"automatic_taxes": true,
|
||||||
"created_at": Any<Date>,
|
"created_at": Any<Date>,
|
||||||
@@ -3937,7 +3938,7 @@ const plugins = [
|
|||||||
order_placed_template: process.env.SENDGRID_ORDER_PLACED_ID,
|
order_placed_template: process.env.SENDGRID_ORDER_PLACED_ID,
|
||||||
localization: {
|
localization: {
|
||||||
"de-DE": { // locale key
|
"de-DE": { // locale key
|
||||||
order_placed_template:
|
order_placed_template:
|
||||||
process.env.SENDGRID_ORDER_PLACED_ID_LOCALIZED,
|
process.env.SENDGRID_ORDER_PLACED_ID_LOCALIZED,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class SendGridService extends NotificationService {
|
|||||||
fulfillmentProviderService,
|
fulfillmentProviderService,
|
||||||
totalsService,
|
totalsService,
|
||||||
productVariantService,
|
productVariantService,
|
||||||
|
giftCardService,
|
||||||
},
|
},
|
||||||
options
|
options
|
||||||
) {
|
) {
|
||||||
@@ -49,6 +50,7 @@ class SendGridService extends NotificationService {
|
|||||||
this.fulfillmentService_ = fulfillmentService
|
this.fulfillmentService_ = fulfillmentService
|
||||||
this.totalsService_ = totalsService
|
this.totalsService_ = totalsService
|
||||||
this.productVariantService_ = productVariantService
|
this.productVariantService_ = productVariantService
|
||||||
|
this.giftCardService_ = giftCardService
|
||||||
|
|
||||||
SendGrid.setApiKey(options.api_key)
|
SendGrid.setApiKey(options.api_key)
|
||||||
}
|
}
|
||||||
@@ -579,20 +581,16 @@ class SendGridService extends NotificationService {
|
|||||||
const giftCard = await this.giftCardService_.retrieve(id, {
|
const giftCard = await this.giftCardService_.retrieve(id, {
|
||||||
relations: ["region", "order"],
|
relations: ["region", "order"],
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!giftCard.order) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = await this.extractLocale(order)
|
const email = giftCard.order ? giftCard.order.email : giftCard.metadata.email;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...giftCard,
|
...giftCard,
|
||||||
locale,
|
locale,
|
||||||
email: giftCard.order.email,
|
email,
|
||||||
display_value: giftCard.value * (1 + taxRate),
|
display_value: `${this.humanPrice_((giftCard.value * 1+ taxRate), giftCard.region.currency_code)} ${giftCard.region.currency_code}`,
|
||||||
|
message: giftCard.metadata?.message || giftCard.metadata?.personal_message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user