Skip to content

Commit 8d7a0ad

Browse files
committed
manage the mobile phone #1847 for magento 2.3.6-p1
1 parent 9baa66a commit 8d7a0ad

File tree

6 files changed

+203
-129
lines changed

6 files changed

+203
-129
lines changed

Block/Subscribe.php

+39-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Ebizmarts\MailChimp\Block;
44

5+
use Magento\Customer\Model\Session;
6+
use Magento\Customer\Api\CustomerRepositoryInterface;
7+
use Magento\Customer\Model\CustomerFactory;
58
use Magento\Framework\View\Element\Template;
69
use \Ebizmarts\MailChimp\Helper\Data as MailchimpHelper;
710

@@ -15,31 +18,66 @@ class Subscribe extends \Magento\Newsletter\Block\Subscribe
1518
* @var MailchimpHelper
1619
*/
1720
protected $helper;
21+
/**
22+
* @var Session
23+
*/
24+
private $customerSession;
25+
/**
26+
* @var CustomerRepositoryInterface
27+
*/
28+
private $customerRepo;
29+
/**
30+
* @var CustomerFactory
31+
*/
32+
private $customerFactory;
1833

1934
/**
2035
* @param Template\Context $context
2136
* @param MailchimpHelper $helper
37+
* @param Session $customerSession
38+
* @param CustomerRepositoryInterface $customerRepo
39+
* @param CustomerFactory $customerFactory
2240
* @param array $data
2341
*/
2442
public function __construct(
2543
Template\Context $context,
2644
MailchimpHelper $helper,
45+
Session $customerSession,
46+
CustomerRepositoryInterface $customerRepo,
47+
CustomerFactory $customerFactory,
2748
array $data = []
2849
)
2950
{
3051
parent::__construct($context, $data);
3152
$this->context = $context;
3253
$this->helper = $helper;
54+
$this->customerSession = $customerSession;
55+
$this->customerRepo = $customerRepo;
56+
$this->customerFactory = $customerFactory;
3357
}
3458

3559
public function getPopupUrl()
3660
{
37-
3861
$storeId = $this->context->getStoreManager()->getStore()->getId();
3962
return $this->helper->getConfigValue(MailchimpHelper::XML_POPUP_URL,$storeId);
4063
}
4164
public function getFormActionUrl()
4265
{
4366
return $this->getUrl('mailchimp/subscriber/subscribe', ['_secure' => true]);
4467
}
68+
public function showMobilePhone()
69+
{
70+
$ret = true;
71+
if ($this->customerSession->getCustomerId()) {
72+
/**
73+
* @var $customer \Magento\Customer\Model\Customer
74+
*/
75+
$customer = $this->customerFactory->create()->load($this->customerSession->getCustomerId());
76+
$mobilePhone = $customer->getData('mobile_phone');
77+
if ($mobilePhone&&$mobilePhone!='') {
78+
$ret = false;
79+
}
80+
}
81+
return $ret;
82+
}
4583
}

0 commit comments

Comments
 (0)