Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Reorder Class Reference
Inheritance diagram for Reorder:
AbstractHelper

Public Member Functions

 __construct (\Magento\Framework\App\Helper\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Sales\Api\OrderRepositoryInterface $orderRepository)
 
 isAllow ()
 
 isAllowed ($store=null)
 
 canReorder ($orderId)
 
- Public Member Functions inherited from AbstractHelper
 __construct (Context $context)
 
 isModuleOutputEnabled ($moduleName=null)
 

Data Fields

const XML_PATH_SALES_REORDER_ALLOW = 'sales/reorder/allow'
 

Protected Attributes

 $customerSession
 
 $orderRepository
 
- Protected Attributes inherited from AbstractHelper
 $_moduleName
 
 $_request
 
 $_moduleManager
 
 $_logger
 
 $_urlBuilder
 
 $_httpHeader
 
 $_eventManager
 
 $_remoteAddress
 
 $urlEncoder
 
 $urlDecoder
 
 $scopeConfig
 
 $_cacheConfig
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractHelper
 _getRequest ()
 
 _getModuleName ()
 
 _getUrl ($route, $params=[])
 

Detailed Description

Sales module base helper

Definition at line 12 of file Reorder.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Helper\Context  $context,
\Magento\Customer\Model\Session  $customerSession,
\Magento\Sales\Api\OrderRepositoryInterface  $orderRepository 
)
Parameters
\Magento\Framework\App\Helper\Context$context
\Magento\Customer\Model\Session$customerSession
\Magento\Sales\Api\OrderRepositoryInterface$orderRepository

Definition at line 31 of file Reorder.php.

35  {
36  $this->orderRepository = $orderRepository;
37  $this->customerSession = $customerSession;
38  parent::__construct(
39  $context
40  );
41  }

Member Function Documentation

◆ canReorder()

canReorder (   $orderId)

Check is it possible to reorder

Parameters
int$orderId
Returns
bool

Definition at line 75 of file Reorder.php.

76  {
77  $order = $this->orderRepository->get($orderId);
78  if (!$this->isAllowed($order->getStore())) {
79  return false;
80  }
81  if ($this->customerSession->isLoggedIn()) {
82  return $order->canReorder();
83  } else {
84  return true;
85  }
86  }
$order
Definition: order.php:55

◆ isAllow()

isAllow ( )
Returns
bool

Definition at line 46 of file Reorder.php.

47  {
48  return $this->isAllowed();
49  }

◆ isAllowed()

isAllowed (   $store = null)

Check if reorder is allowed for given store

Parameters
\Magento\Store\Model\Store | int | null$store
Returns
bool

Definition at line 57 of file Reorder.php.

58  {
59  if ($this->scopeConfig->getValue(
60  self::XML_PATH_SALES_REORDER_ALLOW,
61  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
62  $store
63  )) {
64  return true;
65  }
66  return false;
67  }

Field Documentation

◆ $customerSession

$customerSession
protected

Definition at line 19 of file Reorder.php.

◆ $orderRepository

$orderRepository
protected

Definition at line 24 of file Reorder.php.

◆ XML_PATH_SALES_REORDER_ALLOW

const XML_PATH_SALES_REORDER_ALLOW = 'sales/reorder/allow'

Definition at line 14 of file Reorder.php.


The documentation for this class was generated from the following file: