diff --git a/Block/Subscribe.php b/Block/Subscribe.php
index 1012a305..23d85fc6 100644
--- a/Block/Subscribe.php
+++ b/Block/Subscribe.php
@@ -3,7 +3,10 @@
namespace Ebizmarts\MailChimp\Block;
use Magento\Framework\View\Element\Template;
-use \Ebizmarts\MailChimp\Helper\Data as MailchimpHelper;
+use Magento\Customer\Model\Session;
+use Magento\Customer\Api\CustomerRepositoryInterface;
+use Magento\Customer\Model\CustomerFactory;
+use Ebizmarts\MailChimp\Helper\Data as MailchimpHelper;
class Subscribe extends \Magento\Newsletter\Block\Subscribe
{
@@ -15,21 +18,38 @@ class Subscribe extends \Magento\Newsletter\Block\Subscribe
* @var MailchimpHelper
*/
protected $helper;
+ /**
+ * @var Session
+ */
+ private $customerSession;
+ /**
+ * @var CustomerRepositoryInterface
+ */
+ private $customerRepo;
+ private $customerFactory;
/**
* @param Template\Context $context
* @param MailchimpHelper $helper
+ * @param Session $customerSession
+ * @param CustomerRepositoryInterface $customerRepo
* @param array $data
*/
public function __construct(
Template\Context $context,
MailchimpHelper $helper,
+ Session $customerSession,
+ CustomerRepositoryInterface $customerRepo,
+ CustomerFactory $customerFactory,
array $data = []
)
{
parent::__construct($context, $data);
$this->context = $context;
$this->helper = $helper;
+ $this->customerSession = $customerSession;
+ $this->customerRepo = $customerRepo;
+ $this->customerFactory = $customerFactory;
}
public function getPopupUrl()
@@ -38,4 +58,23 @@ public function getPopupUrl()
$storeId = $this->context->getStoreManager()->getStore()->getId();
return $this->helper->getConfigValue(MailchimpHelper::XML_POPUP_URL,$storeId);
}
-}
\ No newline at end of file
+ public function getFormActionUrl()
+ {
+ return $this->getUrl('mailchimp/subscriber/subscribe', ['_secure' => true]);
+ }
+ public function showMobilePhone()
+ {
+ $ret = true;
+ if ($this->customerSession->getCustomerId()) {
+ /**
+ * @var $customer \Magento\Customer\Model\Customer
+ */
+ $customer = $this->customerFactory->create()->load($this->customerSession->getCustomerId());
+ $mobilePhone = $customer->getData('mobile_phone');
+ if ($mobilePhone&&$mobilePhone!='') {
+ $ret = false;
+ }
+ }
+ return $ret;
+ }
+}
diff --git a/Controller/Subscriber/Subscribe.php b/Controller/Subscriber/Subscribe.php
new file mode 100644
index 00000000..afac0920
--- /dev/null
+++ b/Controller/Subscriber/Subscribe.php
@@ -0,0 +1,44 @@
+session = $customerSession;
+ parent::__construct($context, $subscriberFactory, $customerSession, $storeManager, $customerUrl, $customerAccountManagement, $subscriptionManager, $emailValidator, $customerRepository);
+ }
+
+ public function execute()
+ {
+ if($this->getRequest()->isPost() && $this->getRequest()->getPost('phone')) {
+ $phone = (string)$this->getRequest()->getPost('phone');
+ $this->session->setPhone($phone);
+ }
+ return parent::execute();
+ }
+}
diff --git a/Controller/WebHook/Index.php b/Controller/WebHook/Index.php
index 9bb6131a..f776319d 100644
--- a/Controller/WebHook/Index.php
+++ b/Controller/WebHook/Index.php
@@ -52,7 +52,7 @@ public function __construct(
\Ebizmarts\MailChimp\Model\MailChimpWebhookRequestFactory $chimpWebhookRequestFactory,
\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
) {
-
+
parent::__construct($context);
$this->_resultFactory = $context->getResultFactory();
$this->_helper = $helper;
@@ -111,6 +111,8 @@ public function execute()
$this->_helper->log($request['data']);
$result->setHttpResponseCode(403);
}
+ } else {
+ $this->_helper->log("The two way is off");
}
} else {
$this->_helper->log('An empty request comes from ip: '.$this->_remoteAddress->getRemoteAddress());
diff --git a/Cron/Webhook.php b/Cron/Webhook.php
index 46b4afd3..5859d924 100644
--- a/Cron/Webhook.php
+++ b/Cron/Webhook.php
@@ -149,8 +149,9 @@ protected function _subscribe($data)
$storeIds = $this->_helper->getMagentoStoreIdsByListId($listId);
if (count($storeIds) > 0) {
foreach ($storeIds as $storeId) {
+ $websiteId = $this->storeManager->getStore($storeId)->getWebsiteId();
$sub = $this->_subscriberFactory->create();
- $sub->setStoreId($storeId);
+ $sub->setStoreId($websiteId);
$sub->setSubscriberEmail($email);
$this->_subscribeMember($sub, \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED);
}
@@ -247,7 +248,8 @@ protected function _profile($data)
$stores = $this->_helper->getMagentoStoreIdsByListId($listId);
if (count($stores)) {
- $subscriber->setStoreId($stores[0]);
+ $websiteId = $this->storeManager->getStore($stores[0])->getWebsiteId();
+ $subscriber->setStoreId($websiteId);
try {
$api = $this->_helper->getApi($stores[0]);
$member = $api->lists->members->get($listId, hash('md5', strtolower($email)));
diff --git a/Helper/Data.php b/Helper/Data.php
index 00c9ebce..8c359f0e 100755
--- a/Helper/Data.php
+++ b/Helper/Data.php
@@ -11,10 +11,30 @@
namespace Ebizmarts\MailChimp\Helper;
-use Magento\Framework\App\ResourceConnection;
-use Magento\Framework\Exception\ValidatorException;
-use Magento\Store\Model\Store;
use Symfony\Component\Config\Definition\Exception\Exception;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\App\DeploymentConfig;
+use Magento\Framework\App\Cache\TypeListInterface;
+use Magento\Framework\App\Helper\Context;
+use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Framework\Locale\Resolver;
+use Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
+use Magento\Framework\Module\ModuleList\Loader;
+use Magento\Framework\Encryption\Encryptor;
+use Magento\Directory\Api\CountryInformationAcquirerInterface;
+use Magento\Directory\Model\CountryFactory;
+use Magento\Customer\Model\Session;
+use Magento\Customer\Api\CustomerRepositoryInterface;
+use Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory as AttributeCollectionFactory;
+use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory;
+use Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory as SubscriberCollectionFactory;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Config\Model\ResourceModel\Config;
+use Ebizmarts\MailChimp\Model\Logger\Logger;
+use Ebizmarts\MailChimp\Model\MailChimpSyncBatches;
+use Ebizmarts\MailChimp\Model\MailChimpStoresFactory;
+use Ebizmarts\MailChimp\Model\MailChimpStores;
+use Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
@@ -52,6 +72,8 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
const XML_POPUP_FORM = 'mailchimp/general/popup_form';
const XML_POPUP_URL = 'mailchimp/general/popup_url';
const XML_CLEAN_ERROR_MONTHS = 'mailchimp/ecommerce/clean_errors_months';
+ const XML_FOOTER_PHONE = 'mailchimp/general/footer_phone';
+ const XML_FOOTER_MAP = 'mailchimp/general/footer_phone_map';
const ORDER_STATE_OK = 'complete';
@@ -95,11 +117,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
protected $counters = [];
/**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var StoreManagerInterface
*/
private $_storeManager;
/**
- * @var \Ebizmarts\MailChimp\Model\Logger\Logger
+ * @var Logger
*/
private $_mlogger;
/**
@@ -111,139 +133,144 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
*/
protected $_request;
/**
- * @var \Magento\Framework\Module\ModuleList\Loader
+ * @var Loader
*/
private $_loader;
/**
- * @var \Magento\Config\Model\ResourceModel\Config
+ * @var Config
*/
private $_config;
/**
* @var \Mailchimp
*/
private $_api;
-
/**
- * @var \Ebizmarts\MailChimp\Model\MailChimpSyncBatches
+ * @var MailChimpSyncBatches
*/
private $_syncBatches;
/**
- * @var \Ebizmarts\MailChimp\Model\MailChimpStoresFactory
+ * @var MailChimpStoresFactory
*/
private $_mailChimpStoresFactory;
/**
- * @var \Ebizmarts\MailChimp\Model\MailChimpStores
+ * @var MailChimpStores
*/
private $_mailChimpStores;
/**
- * @var \Magento\Framework\Encryption\Encryptor
+ * @var Encryptor
*/
private $_encryptor;
/**
- * @var \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory
+ * @var SubscriberCollectionFactory
*/
private $_subscriberCollection;
/**
- * @var \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory
+ * @var CustomerCollectionFactory
*/
private $_customerCollection;
/**
- * @var \Magento\Framework\App\ResourceConnection
+ * @var ResourceConnection
*/
private $_resource;
/**
- * @var \Magento\Framework\App\Cache\TypeListInterface
+ * @var TypeListInterface
*/
private $_cacheTypeList;
/**
- * @var \Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory
+ * @var AttributeCollectionFactory
*/
private $_attCollection;
/**
- * @var \Magento\Customer\Model\CustomerFactory
+ * @var CustomerRepositoryInterface
*/
- protected $_customerFactory;
+ protected $_customerRepo;
/**
- * @var \Magento\Directory\Api\CountryInformationAcquirerInterface
+ * @var CountryInformationAcquirerInterface
*/
protected $_countryInformation;
/**
- * @var \Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory
+ * @var MailChimpInterestGroupFactory
*/
protected $_interestGroupFactory;
/**
- * @var \Magento\Framework\Stdlib\DateTime\DateTime
+ * @var DateTime
*/
protected $_date;
/**
- * @var \Magento\Framework\App\DeploymentConfig
+ * @var DeploymentConfig
*/
protected $_deploymentConfig;
/**
- * @var \Magento\Framework\Serialize\Serializer\Json
+ * @var JsonSerializer
*/
protected $_serializer;
/**
- * @var \Magento\Directory\Model\CountryFactory
+ * @var CountryFactory
*/
protected $countryFactory;
/**
- * @var \Magento\Framework\Locale\Resolver
+ * @var Resolver
*/
protected $resolver;
private $customerAtt = null;
private $addressAtt = null;
private $_mapFields = null;
+ /**
+ * @var Session
+ */
+ private $customerSession = null;
/**
- * @param \Magento\Framework\App\Helper\Context $context
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- * @param \Ebizmarts\MailChimp\Model\Logger\Logger $logger
- * @param \Magento\Framework\Module\ModuleList\Loader $loader
- * @param \Magento\Config\Model\ResourceModel\Config $config
+ * @param Context $context
+ * @param StoreManagerInterface $storeManager
+ * @param Logger $logger
+ * @param Loader $loader
+ * @param Config $config
* @param \Mailchimp $api
- * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
- * @param \Ebizmarts\MailChimp\Model\MailChimpSyncBatches $syncBatches
- * @param \Ebizmarts\MailChimp\Model\MailChimpStoresFactory $mailChimpStoresFactory
- * @param \Ebizmarts\MailChimp\Model\MailChimpStores $mailChimpStores
- * @param \Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory $attCollection
- * @param \Magento\Framework\Encryption\Encryptor $encryptor
- * @param \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory $subscriberCollection
- * @param \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory $customerCollection
- * @param \Magento\Customer\Model\CustomerFactory $customerFactory
- * @param \Magento\Directory\Api\CountryInformationAcquirerInterface $countryInformation
+ * @param TypeListInterface $cacheTypeList
+ * @param MailChimpSyncBatches $syncBatches
+ * @param MailChimpStoresFactory $mailChimpStoresFactory
+ * @param MailChimpStores $mailChimpStores
+ * @param AttributeCollectionFactory $attCollection
+ * @param Encryptor $encryptor
+ * @param SubscriberCollectionFactory $subscriberCollection
+ * @param CustomerCollectionFactory $customerCollection
+ * @param CustomerRepositoryInterface $customerRepository
+ * @param CountryInformationAcquirerInterface $countryInformation
* @param ResourceConnection $resource
- * @param \Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory
- * @param \Magento\Framework\Serialize\Serializer\Json $serializer
- * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
- * @param \Magento\Framework\Stdlib\DateTime\DateTime $date
- * @param \Magento\Directory\Model\CountryFactory $countryFactory
- * @param \Magento\Framework\Locale\Resolver $resolver
+ * @param MailChimpInterestGroupFactory $interestGroupFactory
+ * @param JsonSerializer $serializer
+ * @param DeploymentConfig $deploymentConfig
+ * @param DateTime $date
+ * @param CountryFactory $countryFactory
+ * @param Resolver $resolver
+ * @param Session $customerSession
*/
public function __construct(
- \Magento\Framework\App\Helper\Context $context,
- \Magento\Store\Model\StoreManagerInterface $storeManager,
- \Ebizmarts\MailChimp\Model\Logger\Logger $logger,
- \Magento\Framework\Module\ModuleList\Loader $loader,
- \Magento\Config\Model\ResourceModel\Config $config,
+ Context $context,
+ StoreManagerInterface $storeManager,
+ Logger $logger,
+ Loader $loader,
+ Config $config,
\Mailchimp $api,
- \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
- \Ebizmarts\MailChimp\Model\MailChimpSyncBatches $syncBatches,
- \Ebizmarts\MailChimp\Model\MailChimpStoresFactory $mailChimpStoresFactory,
- \Ebizmarts\MailChimp\Model\MailChimpStores $mailChimpStores,
- \Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory $attCollection,
- \Magento\Framework\Encryption\Encryptor $encryptor,
- \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory $subscriberCollection,
- \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory $customerCollection,
- \Magento\Customer\Model\CustomerFactory $customerFactory,
- \Magento\Directory\Api\CountryInformationAcquirerInterface $countryInformation,
- \Magento\Framework\App\ResourceConnection $resource,
- \Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory,
- \Magento\Framework\Serialize\Serializer\Json $serializer,
- \Magento\Framework\App\DeploymentConfig $deploymentConfig,
- \Magento\Framework\Stdlib\DateTime\DateTime $date,
- \Magento\Directory\Model\CountryFactory $countryFactory,
- \Magento\Framework\Locale\Resolver $resolver
+ TypeListInterface $cacheTypeList,
+ MailChimpSyncBatches $syncBatches,
+ MailChimpStoresFactory $mailChimpStoresFactory,
+ MailChimpStores $mailChimpStores,
+ AttributeCollectionFactory $attCollection,
+ Encryptor $encryptor,
+ SubscriberCollectionFactory $subscriberCollection,
+ CustomerCollectionFactory $customerCollection,
+ CustomerRepositoryInterface $customerRepository,
+ CountryInformationAcquirerInterface $countryInformation,
+ ResourceConnection $resource,
+ MailChimpInterestGroupFactory $interestGroupFactory,
+ JsonSerializer $serializer,
+ DeploymentConfig $deploymentConfig,
+ DateTime $date,
+ CountryFactory $countryFactory,
+ Resolver $resolver,
+ Session $customerSession
) {
$this->_storeManager = $storeManager;
@@ -262,7 +289,7 @@ public function __construct(
$this->_resource = $resource;
$this->_cacheTypeList = $cacheTypeList;
$this->_attCollection = $attCollection;
- $this->_customerFactory = $customerFactory;
+ $this->_customerRepo = $customerRepository;
$this->_countryInformation = $countryInformation;
$this->_interestGroupFactory = $interestGroupFactory;
$this->_serializer = $serializer;
@@ -270,6 +297,7 @@ public function __construct(
$this->_date = $date;
$this->countryFactory = $countryFactory;
$this->resolver = $resolver;
+ $this->customerSession = $customerSession;
parent::__construct($context);
}
@@ -387,7 +415,7 @@ private function getAddressAtt()
$ret[$item] = [
'attCode' => $item,
'isDate' => false,
- 'isAddress' => false,
+ 'isAddress' => true,
'options' => []
];
}
@@ -720,23 +748,36 @@ private function _getAddressValues(\Magento\Customer\Model\Address\AbstractAddre
public function getMergeVarsBySubscriber(\Magento\Newsletter\Model\Subscriber $subscriber, $email = null)
{
$mergeVars = [];
- $storeId = $subscriber->getStoreId();
- $webSiteId = $this->getWebsiteId($subscriber->getStoreId());
+ $webSiteId = $subscriber->getStoreId();
+ if ($this->getConfigValue(self::XML_FOOTER_PHONE, $webSiteId, "websites")) {
+ $phone_field = $this->getConfigValue(self::XML_FOOTER_MAP , $webSiteId, "websites");
+ $phone = $subscriber->getPhone();
+ if ($phone_field && $phone) {
+ $mergeVars[$phone_field] = $phone;
+ }
+ }
if (!$email) {
$email = $subscriber->getEmail();
}
- try {
- /**
- * @var $customer \Magento\Customer\Model\Customer
- */
- $customer = $this->_customerFactory->create();
- $customer->setWebsiteId($webSiteId);
- $customer->loadByEmail($email);
- if ($customer->getData('email') == $email) {
- $mergeVars = $this->getMergeVars($customer, $storeId);
+ if ($this->customerSession->getCustomerId()) {
+ try {
+ /**
+ * @var $customer \Magento\Customer\Model\Customer
+ */
+ $customer = $this->_customerRepo->getById($this->customerSession->getCustomerId());
+ if ($customer->getData('mobile_phone')) {
+ $this->log($customer->getData('mobile_phone'));
+ } else {
+ $this->log('no mobile phone');
+ }
+ if ($customer->getData('email') == $email) {
+ $mergeVars = array_merge($mergeVars, $this->getMergeVars($customer, $customer->getStoreId()));
+ }
+ } catch (\Exception $e) {
+ $this->log($e->getMessage());
}
- } catch (\Exception $e) {
- $this->log($e->getMessage());
+ } else {
+ $this->log("Subscriber is not a customer");
}
return $mergeVars;
}
@@ -971,12 +1012,15 @@ public function deleteWebHook($apikey, $listId)
public function loadListSubscribers($listId, $mail)
{
$collection = null;
+ $websiteIds = [];
$storeIds = $this->getMagentoStoreIdsByListId($listId);
- $storeIds[] = 0;
- if (count($storeIds) > 0) {
+ foreach($storeIds as $storeId) {
+ $websiteIds[] =$this->_storeManager->getStore($storeId)->getWebsiteId();
+ }
+ if (count($websiteIds) > 0) {
$collection = $this->_subscriberCollection->create();
$collection
- ->addFieldToFilter('store_id', ['in'=>$storeIds])
+ ->addFieldToFilter('store_id', ['in'=>$websiteIds])
->addFieldToFilter('subscriber_email', ['eq'=>$mail]);
}
return $collection;
diff --git a/Model/Config/Source/Maps.php b/Model/Config/Source/Maps.php
new file mode 100644
index 00000000..3149c708
--- /dev/null
+++ b/Model/Config/Source/Maps.php
@@ -0,0 +1,53 @@
+getParam("store", 0);
+ if ($request->getParam('website', 0)) {
+ $scope = 'website';
+ $storeId = $request->getParam('website', 0);
+ } elseif ($request->getParam('store', 0)) {
+ $scope = 'stores';
+ $storeId = $request->getParam('store', 0);
+ } else {
+ $scope = 'default';
+ }
+
+ if ($helper->getApiKey($storeId, $scope)) {
+ try {
+ $this->options = $helper->getApi($storeId, $scope)->lists->mergeFields->getAll(
+ $helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST, $storeId, $scope),
+ null,
+ null,
+ MailchimpHelper::MAX_MERGEFIELDS
+ );
+ } catch (\Mailchimp_Error $e) {
+ $helper->log($e->getFriendlyMessage());
+ }
+ }
+
+ }
+ public function toOptionArray()
+ {
+ if (is_array($this->options)&&key_exists('merge_fields', $this->options)) {
+ $rc = [];
+ foreach ($this->options['merge_fields'] as $item) {
+ $rc[$item['tag']] = $item['tag'] . ' (' . $item['name'] . ' : ' . $item['type'] . ')';
+ }
+ } else {
+ $rc[] = ['value' => 0, 'label' => __('---No Data---')];
+ }
+ return $rc;
+ }
+}
diff --git a/Model/Plugin/SubscriptionManager.php b/Model/Plugin/SubscriptionManager.php
index 21825f50..3ab5e3de 100644
--- a/Model/Plugin/SubscriptionManager.php
+++ b/Model/Plugin/SubscriptionManager.php
@@ -12,10 +12,10 @@
namespace Ebizmarts\MailChimp\Model\Plugin;
use Magento\Newsletter\Model\SubscriberFactory;
-use \Ebizmarts\MailChimp\Helper\Data as Helper;
-use \Magento\Customer\Model\ResourceModel\CustomerRepository;
-use \Magento\Customer\Model\Session;
-use \Magento\Store\Model\StoreManagerInterface;
+use Ebizmarts\MailChimp\Helper\Data as Helper;
+use Magento\Customer\Model\ResourceModel\CustomerRepository;
+use Magento\Customer\Model\Session;
+use Magento\Store\Model\StoreManagerInterface;
class SubscriptionManager
{
@@ -161,6 +161,9 @@ public function beforeSubscribe(
$websiteId = (int)$this->_storeManager->getStore($storeId)->getWebsiteId();
$subscriber = $this->_subscriberFactory->create()->loadBySubscriberEmail($email, $websiteId);
+ if ($this->_customerSession->getPhone()) {
+ $subscriber->setPhone($this->_customerSession->getPhone());
+ }
if ($this->_helper->isMailChimpEnabled($storeId)) {
$api = $this->_helper->getApi($storeId);
diff --git a/Model/ResourceModel/Newsletter/Collection.php b/Model/ResourceModel/Newsletter/Collection.php
new file mode 100644
index 00000000..b46d2560
--- /dev/null
+++ b/Model/ResourceModel/Newsletter/Collection.php
@@ -0,0 +1,14 @@
+showCustomerInfo(true)->addSubscriberTypeField()->showStoreInfo();
+ $this->_map['fields']['phone'] = 'main_table.phone';
+ return $this;
+ }
+}
diff --git a/Observer/Subscriber/SaveBefore.php b/Observer/Subscriber/SaveBefore.php
new file mode 100644
index 00000000..a41ca31d
--- /dev/null
+++ b/Observer/Subscriber/SaveBefore.php
@@ -0,0 +1,34 @@
+customerSession = $customerSession;
+ }
+ public function execute(Observer $observer)
+ {
+ // TODO: Implement execute() method.
+ $subscriber = $observer->getSubscriber();
+ if ($this->customerSession->getPhone()) {
+ $subscriber->setPhone($this->customerSession->getPhone());
+ $this->customerSession->unsPhone();
+ }
+ return $subscriber;
+ }
+}
diff --git a/Setup/Patch/Data/PhoneSMSCustomerAttribute.php b/Setup/Patch/Data/PhoneSMSCustomerAttribute.php
new file mode 100644
index 00000000..92ee2fc1
--- /dev/null
+++ b/Setup/Patch/Data/PhoneSMSCustomerAttribute.php
@@ -0,0 +1,98 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->eavSetupFactory = $eavSetupFactory;
+ $this->eavConfig = $eavConfig;
+ $this->attributeResource = $attributeResource;
+ }
+ public function apply()
+ {
+ $this->moduleDataSetup->getConnection()->startSetup();
+ $this->addPhoneSMSAttribute();
+ $this->moduleDataSetup->getConnection()->endSetup();
+ }
+ private function addPhoneSMSAttribute()
+ {
+ $eavSetup = $this->eavSetupFactory->create();
+ $eavSetup->addAttribute(
+ \Magento\Customer\Model\Customer::ENTITY,
+ 'mobile_phone',
+ [
+ 'label' => 'Mobile Phone',
+ 'required' => false,
+ 'position' => 100,
+ 'system' => false,
+ 'visible' => true,
+ 'user_defined' => 1,
+ 'input' => 'text'
+ ]
+ );
+
+ $attributeSetId = $eavSetup->getDefaultAttributeSetId(Customer::ENTITY);
+ $attributeGroupId = $eavSetup->getDefaultAttributeGroupId(Customer::ENTITY);
+
+ $attribute = $this->eavConfig->getAttribute(Customer::ENTITY, 'mobile_phone');
+ $attribute->setData('attribute_set_id', $attributeSetId);
+ $attribute->setData('attribute_group_id', $attributeGroupId);
+
+ $attribute->setData('used_in_forms', [
+ 'adminhtml_customer',
+ 'customer_account_edit'
+ ]);
+
+ $this->attributeResource->save($attribute);
+ }
+
+ public function revert()
+ {
+ }
+ public function getAliases()
+ {
+ return [];
+ }
+ public static function getDependencies()
+ {
+ return [];
+ }
+}
diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml
new file mode 100644
index 00000000..adeadc0a
--- /dev/null
+++ b/etc/adminhtml/di.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 2e3f5b0f..2cebc2d5 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -69,7 +69,7 @@
+
+
-
+
Magento\Config\Model\Config\Source\Yesno
diff --git a/etc/db_schema.xml b/etc/db_schema.xml
index 395f4115..87eef43a 100644
--- a/etc/db_schema.xml
+++ b/etc/db_schema.xml
@@ -148,4 +148,7 @@
+
diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json
index 1a29b7b9..26d1e21f 100644
--- a/etc/db_schema_whitelist.json
+++ b/etc/db_schema_whitelist.json
@@ -155,5 +155,10 @@
"mailchimp_sync_error": true,
"mailchimp_sent": true
}
+ },
+ "newsletter_subscriber": {
+ "column": {
+ "phone": true
+ }
}
}
diff --git a/etc/events.xml b/etc/events.xml
index 0e7e46b1..1ff8bb10 100644
--- a/etc/events.xml
+++ b/etc/events.xml
@@ -26,6 +26,9 @@
+
+
+
diff --git a/view/adminhtml/layout/newsletter_subscriber_block.xml b/view/adminhtml/layout/newsletter_subscriber_block.xml
new file mode 100644
index 00000000..38b82da6
--- /dev/null
+++ b/view/adminhtml/layout/newsletter_subscriber_block.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ Phone
+ phone
+ phone
+ phone
+
+
+
+
+
diff --git a/view/adminhtml/web/js/configapikey.js b/view/adminhtml/web/js/configapikey.js
index c1870881..a7849fde 100644
--- a/view/adminhtml/web/js/configapikey.js
+++ b/view/adminhtml/web/js/configapikey.js
@@ -84,7 +84,21 @@ define(
var abandonedCartEnabled = $('#mailchimp_abandonedcart_active').find(':selected').val();
if (ecommerceEnabled == 0 && abandonedCartEnabled == 1) {
self._changeAbandonedCart();
- }
+ };
+ $('#mailchimp_general_popup_form').change(function () {
+ var popupformEnabled = $('#mailchimp_general_popup_form').find(':selected').val();
+ var footerphoneEnabled = $('#mailchimp_general_footer_phone').find(':selected').val();
+ if (popupformEnabled == 1 && footerphoneEnabled == 1) {
+ self._disableFooterPhone();
+ }
+ });
+ $('#mailchimp_general_footer_phone').change(function () {
+ var popupformEnabled = $('#mailchimp_general_popup_form').find(':selected').val();
+ var footerphoneEnabled = $('#mailchimp_general_footer_phone').find(':selected').val();
+ if (popupformEnabled == 1 && footerphoneEnabled == 1) {
+ self._disablePopupForm();
+ }
+ });
},
_changeEcommerce: function () {
@@ -398,6 +412,36 @@ define(
}
});
});
+ },
+ _disableFooterPhone: function () {
+ var tag = '#mailchimp_general_footer_phone'
+ $(tag).empty();
+ $(tag).append($('