Skip to content

Commit

Permalink
customer att mobile phone #1847 for magento 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Nov 3, 2023
1 parent c5ff022 commit aad6ed4
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 130 deletions.
32 changes: 31 additions & 1 deletion 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,31 +17,59 @@ class Subscribe extends \Magento\Newsletter\Block\Subscribe
* @var MailchimpHelper
*/
protected $helper;
/**
* @var Session
*/
protected $customerSession;
/**
* @var CustomerFactory
*/
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()
{

$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 aad6ed4

Please sign in to comment.