Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Reorder.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Sales\Helper;
8 
13 {
14  const XML_PATH_SALES_REORDER_ALLOW = 'sales/reorder/allow';
15 
19  protected $customerSession;
20 
24  protected $orderRepository;
25 
31  public function __construct(
32  \Magento\Framework\App\Helper\Context $context,
33  \Magento\Customer\Model\Session $customerSession,
35  ) {
36  $this->orderRepository = $orderRepository;
37  $this->customerSession = $customerSession;
38  parent::__construct(
39  $context
40  );
41  }
42 
46  public function isAllow()
47  {
48  return $this->isAllowed();
49  }
50 
57  public function isAllowed($store = null)
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  }
68 
75  public function canReorder($orderId)
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  }
87 }
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Sales\Api\OrderRepositoryInterface $orderRepository)
Definition: Reorder.php:31
$order
Definition: order.php:55