Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Success.php
Go to the documentation of this file.
1 <?php
7 
10 
18 {
22  protected $_checkoutSession;
23 
27  protected $_orderConfig;
28 
32  protected $httpContext;
33 
41  public function __construct(
42  \Magento\Framework\View\Element\Template\Context $context,
43  \Magento\Checkout\Model\Session $checkoutSession,
44  \Magento\Sales\Model\Order\Config $orderConfig,
45  \Magento\Framework\App\Http\Context $httpContext,
46  array $data = []
47  ) {
48  parent::__construct($context, $data);
49  $this->_checkoutSession = $checkoutSession;
50  $this->_orderConfig = $orderConfig;
51  $this->_isScopePrivate = true;
52  $this->httpContext = $httpContext;
53  }
54 
60  public function getAdditionalInfoHtml()
61  {
62  return $this->_layout->renderElement('order.success.additional.info');
63  }
64 
70  protected function _beforeToHtml()
71  {
72  $this->prepareBlockData();
73  return parent::_beforeToHtml();
74  }
75 
81  protected function prepareBlockData()
82  {
83  $order = $this->_checkoutSession->getLastRealOrder();
84 
85  $this->addData(
86  [
87  'is_order_visible' => $this->isVisible($order),
88  'view_order_url' => $this->getUrl(
89  'sales/order/view/',
90  ['order_id' => $order->getEntityId()]
91  ),
92  'print_url' => $this->getUrl(
93  'sales/order/print',
94  ['order_id' => $order->getEntityId()]
95  ),
96  'can_print_order' => $this->isVisible($order),
97  'can_view_order' => $this->canViewOrder($order),
98  'order_id' => $order->getIncrementId()
99  ]
100  );
101  }
102 
109  protected function isVisible(Order $order)
110  {
111  return !in_array(
112  $order->getStatus(),
113  $this->_orderConfig->getInvisibleOnFrontStatuses()
114  );
115  }
116 
123  protected function canViewOrder(Order $order)
124  {
125  return $this->httpContext->getValue(Context::CONTEXT_AUTH)
126  && $this->isVisible($order);
127  }
128 
133  public function getContinueUrl()
134  {
135  return $this->_storeManager->getStore()->getBaseUrl();
136  }
137 }
$order
Definition: order.php:55
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Framework\App\Http\Context $httpContext, array $data=[])
Definition: Success.php:41