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