init
This commit is contained in:
Executable
+88
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Magezon
|
||||
*
|
||||
* This source file is subject to the Magezon Software License, which is available at https://magezon.com/license/.
|
||||
* Do not edit or add to this file if you wish to upgrade the to newer versions in the future.
|
||||
* If you wish to customize this module for your needs.
|
||||
* Please refer to https://www.magezon.com for more information.
|
||||
*
|
||||
* @category Magezon
|
||||
* @package Magezon_QuickOrder
|
||||
* @copyright Copyright (C) 2018 Magezon (https://magezon.com)
|
||||
*/
|
||||
|
||||
namespace Magezon\QuickOrder\Helper;
|
||||
|
||||
class Data extends \Magento\Framework\App\Helper\AbstractHelper
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Store\Model\StoreManagerInterface
|
||||
*/
|
||||
protected $storeManager;
|
||||
|
||||
/**
|
||||
* @var \Magento\Customer\Model\Session
|
||||
*/
|
||||
protected $customerSession;
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\App\Helper\Context $context
|
||||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
|
||||
* @param \Magento\Customer\Model\Session $customerSession
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Framework\App\Helper\Context $context,
|
||||
\Magento\Store\Model\StoreManagerInterface $storeManager,
|
||||
\Magento\Customer\Model\Session $customerSession
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->storeManager = $storeManager;
|
||||
$this->customerSession = $customerSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param null|int $store
|
||||
* @return null|string
|
||||
*/
|
||||
public function getConfig($key, $store = null)
|
||||
{
|
||||
$store = $this->storeManager->getStore($store);
|
||||
$websiteId = $store->getWebsiteId();
|
||||
$result = $this->scopeConfig->getValue(
|
||||
'quickorder/' . $key,
|
||||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
|
||||
$store);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return $this->getConfig('general/enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->getConfig('general/title');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isGroupValid()
|
||||
{
|
||||
if ($this->getConfig('general/customer_groups')) {
|
||||
$customerGroupId = $this->customerSession->getCustomer()->getGroupId();
|
||||
$customerGroups = explode(',', $this->getConfig('general/customer_groups'));
|
||||
return in_array($customerGroupId, $customerGroups);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user