Skip to content

Commit

Permalink
manage the mobile phone #1847 for magento 2.3.6-p1
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Nov 2, 2023
1 parent 9baa66a commit 8d7a0ad
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 129 deletions.
40 changes: 39 additions & 1 deletion Block/Subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Ebizmarts\MailChimp\Block;

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

Expand All @@ -15,31 +18,66 @@ class Subscribe extends \Magento\Newsletter\Block\Subscribe
* @var MailchimpHelper
*/
protected $helper;
/**
* @var Session
*/
private $customerSession;
/**
* @var CustomerRepositoryInterface
*/
private $customerRepo;
/**
* @var CustomerFactory
*/
private $customerFactory;

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

public function getPopupUrl()
{

$storeId = $this->context->getStoreManager()->getStore()->getId();
return $this->helper->getConfigValue(MailchimpHelper::XML_POPUP_URL,$storeId);
}
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 8d7a0ad

Please sign in to comment.