Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Items.php
Go to the documentation of this file.
1 <?php
7 
15 {
21  protected $_salesData;
22 
26  protected $_carrierFactory;
27 
37  public function __construct(
38  \Magento\Backend\Block\Template\Context $context,
39  \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
40  \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration,
41  \Magento\Framework\Registry $registry,
42  \Magento\Sales\Helper\Data $salesData,
43  \Magento\Shipping\Model\CarrierFactory $carrierFactory,
44  array $data = []
45  ) {
46  $this->_salesData = $salesData;
47  $this->_carrierFactory = $carrierFactory;
48  parent::__construct($context, $stockRegistry, $stockConfiguration, $registry, $data);
49  }
50 
56  public function getOrder()
57  {
58  return $this->getShipment()->getOrder();
59  }
60 
66  public function getSource()
67  {
68  return $this->getShipment();
69  }
70 
76  public function getShipment()
77  {
78  return $this->_coreRegistry->registry('current_shipment');
79  }
80 
86  protected function _beforeToHtml()
87  {
88  $this->addChild(
89  'submit_button',
90  \Magento\Backend\Block\Widget\Button::class,
91  [
92  'label' => __('Submit Shipment'),
93  'class' => 'save submit-button primary',
94  'onclick' => 'submitShipment(this);'
95  ]
96  );
97 
98  return parent::_beforeToHtml();
99  }
100 
107  public function formatPrice($price)
108  {
109  return $this->getShipment()->getOrder()->formatPrice($price);
110  }
111 
117  public function getUpdateButtonHtml()
118  {
119  return $this->getChildHtml('update_button');
120  }
121 
127  public function getUpdateUrl()
128  {
129  return $this->getUrl('sales/*/updateQty', ['order_id' => $this->getShipment()->getOrderId()]);
130  }
131 
137  public function canSendShipmentEmail()
138  {
139  return $this->_salesData->canSendNewShipmentEmail($this->getOrder()->getStore()->getId());
140  }
141 
147  public function canCreateShippingLabel()
148  {
149  $shippingCarrier = $this->_carrierFactory->create(
150  $this->getOrder()->getShippingMethod(true)->getCarrierCode()
151  );
152  return $shippingCarrier && $shippingCarrier->isShippingLabelsAvailable();
153  }
154 }
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration, \Magento\Framework\Registry $registry, \Magento\Sales\Helper\Data $salesData, \Magento\Shipping\Model\CarrierFactory $carrierFactory, array $data=[])
Definition: Items.php:37
__()
Definition: __.php:13
$price