Adds gift card support
This commit is contained in:
@@ -33,6 +33,9 @@ class SendGridService extends BaseService {
|
||||
async transactionalEmail(event, data) {
|
||||
let templateId
|
||||
switch (event) {
|
||||
case "order.gift_card_created":
|
||||
templateId = this.options_.gift_card_created_template
|
||||
break
|
||||
case "order.placed":
|
||||
templateId = this.options_.order_placed_template
|
||||
break
|
||||
@@ -55,12 +58,14 @@ class SendGridService extends BaseService {
|
||||
return
|
||||
}
|
||||
try {
|
||||
return SendGrid.send({
|
||||
template_id: templateId,
|
||||
from: this.options_.from,
|
||||
to: data.email,
|
||||
dynamic_template_data: data,
|
||||
})
|
||||
if (templateId) {
|
||||
return SendGrid.send({
|
||||
template_id: templateId,
|
||||
from: this.options_.from,
|
||||
to: data.email,
|
||||
dynamic_template_data: data,
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@ class OrderSubscriber {
|
||||
|
||||
this.eventBus_ = eventBusService
|
||||
|
||||
this.eventBus_.subscribe("order.gift_card_created", async (order) => {
|
||||
await this.sendgridService_.transactionalEmail("order.gift_card_created", order)
|
||||
})
|
||||
|
||||
this.eventBus_.subscribe("order.placed", async (order) => {
|
||||
await this.sendgridService_.transactionalEmail("order.placed", order)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user