From b5bf650ec26182be6324bc56e7f6efd744a7131e Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Tue, 23 Mar 2021 11:27:56 +0100 Subject: [PATCH] fix(slack): show discount code flag --- .../src/services/slack.js | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/medusa-plugin-slack-notification/src/services/slack.js b/packages/medusa-plugin-slack-notification/src/services/slack.js index 9a45674fd7..5821191e95 100644 --- a/packages/medusa-plugin-slack-notification/src/services/slack.js +++ b/packages/medusa-plugin-slack-notification/src/services/slack.js @@ -6,6 +6,8 @@ class SlackService extends BaseService { /** * @param {Object} options - options defined in `medusa-config.js` * { + * show_discount_code: If set to true the discount code used will be + * displayed in the order channel. * slack_url: "https://hooks.slack.com/services/...", * admin_orders_url: "https:..../orders" * } @@ -119,17 +121,19 @@ class SlackService extends BaseService { }) } - order.discounts.forEach((d) => { - blocks.push({ - type: "section", - text: { - type: "mrkdwn", - text: `*Promo Code*\t${d.code} ${d.rule.value}${ - d.rule.type === "percentage" ? "%" : ` ${currencyCode}` - }`, - }, + if (this.options_.show_discount_code) { + order.discounts.forEach((d) => { + blocks.push({ + type: "section", + text: { + type: "mrkdwn", + text: `*Promo Code*\t${d.code} ${d.rule.value}${ + d.rule.type === "percentage" ? "%" : ` ${currencyCode}` + }`, + }, + }) }) - }) + } blocks.push({ type: "divider",