Skip to content

Commit

Permalink
Merge pull request #717 from mailchimp/Issue715-2.3
Browse files Browse the repository at this point in the history
closes #715 for magento 2.3
  • Loading branch information
gonzaloebiz authored May 21, 2019
2 parents 4e9f610 + 27ba584 commit 62f1f14
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Model/Plugin/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ public function beforeUnsubscribeCustomerById(
$storeId = $this->getStoreIdFromSubscriber($subscriber);
if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE, $storeId)) {
$subscriber->loadByCustomerId($customerId);
$api = $this->_helper->getApi($storeId);
try {
$md5HashEmail = md5(strtolower($subscriber->getSubscriberEmail()));
$api->lists->members->update($this->_helper->getDefaultList($storeId), $md5HashEmail, null, 'unsubscribed');
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
if ($subscriber->isSubscribed()) {
$api = $this->_helper->getApi($storeId);
try {
$md5HashEmail = md5(strtolower($subscriber->getSubscriberEmail()));
$api->lists->members->update($this->_helper->getDefaultList($storeId), $md5HashEmail, null, 'unsubscribed');
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
}
}
}
return [$customerId];
Expand Down Expand Up @@ -114,9 +116,7 @@ public function beforeSubscribeCustomerById(
}
try {
$emailHash = md5(strtolower($customer->getEmail()));
if (!$subscriber->getMailchimpId()) {
$return = $api->lists->members->addOrUpdate($this->_helper->getDefaultList($storeId), $emailHash, null, $status, $mergeVars, null, null, null, null, $email, $status);
}
$api->lists->members->addOrUpdate($this->_helper->getDefaultList($storeId), $emailHash, null, $status, $mergeVars, null, null, null, null, $email, $status);
} catch (\Mailchimp_Error $e) {
$this->_helper->log($e->getFriendlyMessage());
}
Expand Down

0 comments on commit 62f1f14

Please sign in to comment.