From 7773806abb3b18ec283a12ea77feab3b50683138 Mon Sep 17 00:00:00 2001 From: Tam Date: Mon, 24 Jun 2019 17:24:07 +0100 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=9CSyncing=20Disabled=E2=80=9D=20al?= =?UTF-8?q?ert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/MailchimpCommerce.php | 20 +++++++++++++++++++- src/translations/en/mailchimp-commerce.php | 3 ++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ef4e29..75bbb73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.4 - 2019-06-24 +### Added +- Added alert to the Mailchimp CP section telling the user that syncing is disabled (if it is). + ## 1.0.3 - 2019-06-24 ### Added - Added `disableSyncing` setting to prevent all syncing to Mailchimp diff --git a/composer.json b/composer.json index f4f4501..8147400 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ether/mailchimp-commerce", "description": "Mailchimp integration with Craft Commerce", - "version": "1.0.3", + "version": "1.0.4", "type": "craft-plugin", "keywords": [ "mailchimp", diff --git a/src/MailchimpCommerce.php b/src/MailchimpCommerce.php index 45d0839..15c640f 100644 --- a/src/MailchimpCommerce.php +++ b/src/MailchimpCommerce.php @@ -17,7 +17,9 @@ use craft\commerce\services\Addresses; use craft\errors\ElementNotFoundException; use craft\errors\SiteNotFoundException; +use craft\events\RegisterCpAlertsEvent; use craft\events\RegisterUrlRulesEvent; +use craft\helpers\Cp; use craft\helpers\UrlHelper; use craft\web\UrlManager; use ether\mc\jobs\SyncOrders; @@ -95,6 +97,12 @@ public function init () [$this, 'onAfterSaveAddress'] ); + Event::on( + Cp::class, + Cp::EVENT_REGISTER_ALERTS, + [$this, 'onRegisterAlerts'] + ); + // Events: Products // --------------------------------------------------------------------- @@ -239,6 +247,16 @@ public function onRegisterCpUrlRules (RegisterUrlRulesEvent $event) } } + public function onRegisterAlerts (RegisterCpAlertsEvent $event) + { + if ( + strpos(Craft::$app->getRequest()->getFullPath(), 'mailchimp-commerce') === false || + !$this->getSettings()->disableSyncing + ) return; + + $event->alerts[] = self::t('Mailchimp syncing is disabled.'); + } + // Events: Commerce // ------------------------------------------------------------------------- @@ -387,4 +405,4 @@ public static function t ($message, $params = []) return Craft::t('mailchimp-commerce', $message, $params); } -} \ No newline at end of file +} diff --git a/src/translations/en/mailchimp-commerce.php b/src/translations/en/mailchimp-commerce.php index 9304b36..f1c8929 100644 --- a/src/translations/en/mailchimp-commerce.php +++ b/src/translations/en/mailchimp-commerce.php @@ -10,6 +10,7 @@ 'Mailchimp Commerce' => 'Mailchimp Commerce', 'Never' => 'Never', 'Last Synced to Mailchimp' => 'Last Synced to Mailchimp', + 'Mailchimp syncing is disabled.' => 'Mailchimp syncing is disabled.', // Settings // ========================================================================= @@ -86,4 +87,4 @@ '{synced} of {total, plural, =1{1 promo} other{# promos}} have been synced.' => '{synced} of {total, plural, =1{1 promo} other{# promos}} have been synced.', 'Sync All Promos' => 'Sync All Promos', -]; \ No newline at end of file +];