Skip to content

Commit 64b49d2

Browse files
authored
Merge pull request #22 from luluhoc/no_send_countries_bcc
no_send_countries BCC
2 parents 20de540 + 649479d commit 64b49d2

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "medusa-plugin-sendgrid-typescript",
3-
"version": "2.2.1",
3+
"version": "2.2.2",
44
"description": "SendGrid transactional emails typescript",
55
"repository": {
66
"type": "git",

src/services/sendgrid.ts

+11
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,17 @@ export class SendGridService extends AbstractNotificationService {
297297
attachmentGenerator
298298
)
299299

300+
const toBcc = () => {
301+
if (this.options_.orderPlacedBcc && event === "order.placed") {
302+
303+
if (this.options_?.noSendCountries && this?.options_?.noSendCountries.includes(data.order?.shipping_address?.country_code)) {
304+
return undefined
305+
}
306+
return this.options_.orderPlacedBcc
307+
}
308+
return undefined
309+
}
310+
300311
const sendOptions: SendGrid.MailDataRequired = {
301312
templateId: templateId,
302313
from: this.options_.from,

src/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export interface PluginOptions {
3535
templates: Templates
3636
/** BCC email address to send to when an order is placed. */
3737
orderPlacedBcc?: EmailData|EmailData[]
38+
/** BCC email address to send to when an order is canceled. */
39+
noSendCountries?: string[]
3840
/** locale as key example de-DE */
3941
localization: {
4042
[key: string]: Templates

0 commit comments

Comments
 (0)