Skip to content

Commit

Permalink
add the mobile phone #1847 for magento 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Nov 6, 2023
1 parent 4ca33f9 commit 208ad8a
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 132 deletions.
25 changes: 25 additions & 0 deletions Block/Subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Ebizmarts\MailChimp\Block;

use Magento\Customer\Model\Session;
use Magento\Customer\Model\CustomerFactory;
use Magento\Framework\View\Element\Template;
use \Ebizmarts\MailChimp\Helper\Data as MailchimpHelper;

Expand All @@ -15,21 +17,29 @@ class Subscribe extends \Magento\Newsletter\Block\Subscribe
* @var MailchimpHelper
*/
protected $helper;
protected $customerSession;
protected $customerFactory;

/**
* @param Template\Context $context
* @param MailchimpHelper $helper
* @param Session $customerSession
* @param CustomerFactory $customerFactory
* @param array $data
*/
public function __construct(
Template\Context $context,
MailchimpHelper $helper,
Session $customerSession,
CustomerFactory $customerFactory,
array $data = []
)
{
parent::__construct($context, $data);
$this->context = $context;
$this->helper = $helper;
$this->customerSession = $customerSession;
$this->customerFactory = $customerFactory;
}

public function getPopupUrl()
Expand All @@ -42,4 +52,19 @@ 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;
}
}
Loading

0 comments on commit 208ad8a

Please sign in to comment.