Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Shipment.php
Go to the documentation of this file.
1 <?php
7 
9 
17 {
21  protected $_template = 'Magento_Shipping::order/shipment.phtml';
22 
28  protected $_coreRegistry = null;
29 
33  protected $httpContext;
34 
38  protected $_paymentHelper;
39 
47  public function __construct(
48  \Magento\Framework\View\Element\Template\Context $context,
49  \Magento\Framework\Registry $registry,
50  \Magento\Framework\App\Http\Context $httpContext,
51  \Magento\Payment\Helper\Data $paymentHelper,
52  array $data = []
53  ) {
54  $this->_paymentHelper = $paymentHelper;
55  $this->_coreRegistry = $registry;
56  $this->httpContext = $httpContext;
57  parent::__construct($context, $data);
58  $this->_isScopePrivate = true;
59  }
60 
64  protected function _prepareLayout()
65  {
66  $this->pageConfig->getTitle()->set(__('Order # %1', $this->getOrder()->getRealOrderId()));
67  $infoBlock = $this->_paymentHelper->getInfoBlock($this->getOrder()->getPayment(), $this->getLayout());
68  $this->setChild('payment_info', $infoBlock);
69  }
70 
74  public function getPaymentInfoHtml()
75  {
76  return $this->getChildHtml('payment_info');
77  }
78 
84  public function getOrder()
85  {
86  return $this->_coreRegistry->registry('current_order');
87  }
88 
94  public function getBackUrl()
95  {
96  if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
97  return $this->getUrl('*/*/history');
98  }
99  return $this->getUrl('*/*/form');
100  }
101 
107  public function getBackTitle()
108  {
109  if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
110  return __('Back to My Orders');
111  }
112  return __('View Another Order');
113  }
114 
119  public function getInvoiceUrl($order)
120  {
121  return $this->getUrl('*/*/invoice', ['order_id' => $order->getId()]);
122  }
123 
128  public function getViewUrl($order)
129  {
130  return $this->getUrl('*/*/view', ['order_id' => $order->getId()]);
131  }
132 
137  public function getCreditmemoUrl($order)
138  {
139  return $this->getUrl('*/*/creditmemo', ['order_id' => $order->getId()]);
140  }
141 
147  {
148  return $this->getUrl('*/*/printShipment', ['shipment_id' => $shipment->getId()]);
149  }
150 
156  {
157  return $this->getUrl('*/*/printShipment', ['order_id' => $order->getId()]);
158  }
159 }
$order
Definition: order.php:55
__()
Definition: __.php:13
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Http\Context $httpContext, \Magento\Payment\Helper\Data $paymentHelper, array $data=[])
Definition: Shipment.php:47
foreach($order->getItems() as $orderItem) $shipment