Skip to content

Commit aad6ed4

Browse files
committed
customer att mobile phone #1847 for magento 2.3
1 parent c5ff022 commit aad6ed4

File tree

5 files changed

+201
-130
lines changed

5 files changed

+201
-130
lines changed

Block/Subscribe.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Ebizmarts\MailChimp\Block;
44

5+
use Magento\Customer\Model\Session;
6+
use Magento\Customer\Model\CustomerFactory;
57
use Magento\Framework\View\Element\Template;
68
use \Ebizmarts\MailChimp\Helper\Data as MailchimpHelper;
79

@@ -15,31 +17,59 @@ class Subscribe extends \Magento\Newsletter\Block\Subscribe
1517
* @var MailchimpHelper
1618
*/
1719
protected $helper;
20+
/**
21+
* @var Session
22+
*/
23+
protected $customerSession;
24+
/**
25+
* @var CustomerFactory
26+
*/
27+
protected $customerFactory;
1828

1929
/**
2030
* @param Template\Context $context
2131
* @param MailchimpHelper $helper
32+
* @param Session $customerSession
33+
* @param CustomerFactory $customerFactory
2234
* @param array $data
2335
*/
2436
public function __construct(
2537
Template\Context $context,
2638
MailchimpHelper $helper,
39+
Session $customerSession,
40+
CustomerFactory $customerFactory,
2741
array $data = []
2842
)
2943
{
3044
parent::__construct($context, $data);
3145
$this->context = $context;
3246
$this->helper = $helper;
47+
$this->customerSession = $customerSession;
48+
$this->customerFactory = $customerFactory;
3349
}
3450

3551
public function getPopupUrl()
3652
{
37-
3853
$storeId = $this->context->getStoreManager()->getStore()->getId();
3954
return $this->helper->getConfigValue(MailchimpHelper::XML_POPUP_URL,$storeId);
4055
}
4156
public function getFormActionUrl()
4257
{
4358
return $this->getUrl('mailchimp/subscriber/subscribe', ['_secure' => true]);
4459
}
60+
public function showMobilePhone()
61+
{
62+
$ret = true;
63+
if ($this->customerSession->getCustomerId()) {
64+
/**
65+
* @var $customer \Magento\Customer\Model\Customer
66+
*/
67+
$customer = $this->customerFactory->create()->load($this->customerSession->getCustomerId());
68+
$mobilePhone = $customer->getData('mobile_phone');
69+
if ($mobilePhone&&$mobilePhone!='') {
70+
$ret = false;
71+
}
72+
}
73+
return $ret;
74+
}
4575
}

0 commit comments

Comments
 (0)