Skip to content

Commit

Permalink
Merge pull request #22 from luluhoc/no_send_countries_bcc
Browse files Browse the repository at this point in the history
no_send_countries BCC
  • Loading branch information
luluhoc authored Dec 19, 2024
2 parents 20de540 + 649479d commit 64b49d2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-sendgrid-typescript",
"version": "2.2.1",
"version": "2.2.2",
"description": "SendGrid transactional emails typescript",
"repository": {
"type": "git",
Expand Down
11 changes: 11 additions & 0 deletions src/services/sendgrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@ export class SendGridService extends AbstractNotificationService {
attachmentGenerator
)

const toBcc = () => {
if (this.options_.orderPlacedBcc && event === "order.placed") {

if (this.options_?.noSendCountries && this?.options_?.noSendCountries.includes(data.order?.shipping_address?.country_code)) {
return undefined
}
return this.options_.orderPlacedBcc
}
return undefined
}

const sendOptions: SendGrid.MailDataRequired = {
templateId: templateId,
from: this.options_.from,
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface PluginOptions {
templates: Templates
/** BCC email address to send to when an order is placed. */
orderPlacedBcc?: EmailData|EmailData[]
/** BCC email address to send to when an order is canceled. */
noSendCountries?: string[]
/** locale as key example de-DE */
localization: {
[key: string]: Templates
Expand Down

0 comments on commit 64b49d2

Please sign in to comment.