2
2
3
3
namespace Ebizmarts \MailChimp \Block ;
4
4
5
+ use Magento \Customer \Model \Session ;
6
+ use Magento \Customer \Api \CustomerRepositoryInterface ;
7
+ use Magento \Customer \Model \CustomerFactory ;
5
8
use Magento \Framework \View \Element \Template ;
6
9
use \Ebizmarts \MailChimp \Helper \Data as MailchimpHelper ;
7
10
@@ -15,31 +18,66 @@ class Subscribe extends \Magento\Newsletter\Block\Subscribe
15
18
* @var MailchimpHelper
16
19
*/
17
20
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 ;
18
33
19
34
/**
20
35
* @param Template\Context $context
21
36
* @param MailchimpHelper $helper
37
+ * @param Session $customerSession
38
+ * @param CustomerRepositoryInterface $customerRepo
39
+ * @param CustomerFactory $customerFactory
22
40
* @param array $data
23
41
*/
24
42
public function __construct (
25
43
Template \Context $ context ,
26
44
MailchimpHelper $ helper ,
45
+ Session $ customerSession ,
46
+ CustomerRepositoryInterface $ customerRepo ,
47
+ CustomerFactory $ customerFactory ,
27
48
array $ data = []
28
49
)
29
50
{
30
51
parent ::__construct ($ context , $ data );
31
52
$ this ->context = $ context ;
32
53
$ this ->helper = $ helper ;
54
+ $ this ->customerSession = $ customerSession ;
55
+ $ this ->customerRepo = $ customerRepo ;
56
+ $ this ->customerFactory = $ customerFactory ;
33
57
}
34
58
35
59
public function getPopupUrl ()
36
60
{
37
-
38
61
$ storeId = $ this ->context ->getStoreManager ()->getStore ()->getId ();
39
62
return $ this ->helper ->getConfigValue (MailchimpHelper::XML_POPUP_URL ,$ storeId );
40
63
}
41
64
public function getFormActionUrl ()
42
65
{
43
66
return $ this ->getUrl ('mailchimp/subscriber/subscribe ' , ['_secure ' => true ]);
44
67
}
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
+ }
45
83
}
0 commit comments