-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
409f97d
commit 661ff37
Showing
19 changed files
with
521 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Ebizmarts\MailChimp\Controller\Subscriber; | ||
|
||
use Magento\Customer\Api\AccountManagementInterface as CustomerAccountManagement; | ||
use Magento\Customer\Model\Session; | ||
use Magento\Customer\Model\Url as CustomerUrl; | ||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\App\Action\HttpPostActionInterface; | ||
use Magento\Framework\Validator\EmailAddress as EmailValidator; | ||
use Magento\Newsletter\Controller\Subscriber\NewAction as SubscriberController; | ||
use Magento\Newsletter\Model\SubscriberFactory; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
class Subscribe extends SubscriberController implements HttpPostActionInterface | ||
{ | ||
private $session; | ||
public function __construct( | ||
Context $context, | ||
SubscriberFactory $subscriberFactory, | ||
Session $customerSession, | ||
StoreManagerInterface $storeManager, | ||
CustomerUrl $customerUrl, | ||
CustomerAccountManagement $customerAccountManagement, | ||
EmailValidator $emailValidator = null | ||
) | ||
{ | ||
$this->session = $customerSession; | ||
parent::__construct($context, $subscriberFactory, $customerSession, $storeManager, $customerUrl, $customerAccountManagement, $emailValidator); | ||
} | ||
|
||
public function execute() | ||
{ | ||
if($this->getRequest()->isPost() && $this->getRequest()->getPost('phone')) { | ||
$phone = (string)$this->getRequest()->getPost('phone'); | ||
$this->session->setPhone($phone); | ||
} | ||
return parent::execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Ebizmarts\MailChimp\Model\Config\Source; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
use Ebizmarts\MailChimp\Helper\Data as MailchimpHelper; | ||
use Magento\Framework\App\RequestInterface; | ||
class Maps implements OptionSourceInterface | ||
{ | ||
private $options = null; | ||
public function __construct( | ||
RequestInterface $request, | ||
MailchimpHelper $helper | ||
) | ||
{ | ||
$storeId = (int) $request->getParam("store", 0); | ||
if ($request->getParam('website', 0)) { | ||
$scope = 'website'; | ||
$storeId = $request->getParam('website', 0); | ||
} elseif ($request->getParam('store', 0)) { | ||
$scope = 'stores'; | ||
$storeId = $request->getParam('store', 0); | ||
} else { | ||
$scope = 'default'; | ||
} | ||
|
||
if ($helper->getApiKey($storeId, $scope)) { | ||
try { | ||
$this->options = $helper->getApi($storeId, $scope)->lists->mergeFields->getAll( | ||
$helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST, $storeId, $scope), | ||
null, | ||
null, | ||
MailchimpHelper::MAX_MERGEFIELDS | ||
); | ||
} catch (\Mailchimp_Error $e) { | ||
$helper->log($e->getFriendlyMessage()); | ||
} | ||
} | ||
|
||
} | ||
public function toOptionArray() | ||
{ | ||
if (is_array($this->options)&&key_exists('merge_fields', $this->options)) { | ||
$rc = []; | ||
foreach ($this->options['merge_fields'] as $item) { | ||
$rc[$item['tag']] = $item['tag'] . ' (' . $item['name'] . ' : ' . $item['type'] . ')'; | ||
} | ||
} else { | ||
$rc[] = ['value' => 0, 'label' => __('---No Data---')]; | ||
} | ||
return $rc; | ||
} | ||
} |
Oops, something went wrong.