_shipmentItemFactory = $shipmentItemFactory; $this->_coreRegistry = $registry; parent::__construct($context, $data); } /** * Return collection of shipment items * * @return array */ public function getCollection() { if ($this->getShipment()->getId()) { $collection = $this->_shipmentItemFactory->create()->getCollection()->setShipmentFilter( $this->getShipment()->getId() ); } else { $collection = $this->getShipment()->getAllItems(); } return $collection; } /** * Retrieve shipment model instance * * @return \Magento\Sales\Model\Order\Shipment */ public function getShipment() { return $this->_coreRegistry->registry('current_shipment'); } /** * Can display customs value * * @return bool */ public function displayCustomsValue() { $storeId = $this->getShipment()->getStoreId(); $order = $this->getShipment()->getOrder(); $address = $order->getShippingAddress(); $shipperAddressCountryCode = $this->_scopeConfig->getValue( \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId ); $recipientAddressCountryCode = $address->getCountryId(); if ($shipperAddressCountryCode != $recipientAddressCountryCode) { return true; } return false; } /** * Format price * * @param float $value * @return string */ public function formatPrice($value) { return sprintf('%.2F', $value); } }