50 \
Magento\Framework\Json\EncoderInterface $jsonEncoder,
51 \
Magento\Shipping\Model\Carrier\Source\GenericInterface $sourceSizeModel,
52 \
Magento\Framework\Registry $coreRegistry,
53 \
Magento\Shipping\Model\CarrierFactory $carrierFactory,
56 $this->_jsonEncoder = $jsonEncoder;
57 $this->_coreRegistry = $coreRegistry;
58 $this->_sourceSizeModel = $sourceSizeModel;
59 $this->_carrierFactory = $carrierFactory;
60 parent::__construct($context,
$data);
70 return $this->_coreRegistry->registry(
'current_shipment');
81 $orderId = $this->
getRequest()->getParam(
'order_id');
91 $urlParams[
'shipment_id'] = $shipmentId;
92 $createLabelUrl = $this->
getUrl(
'adminhtml/order_shipment/createLabel', $urlParams);
93 $itemsGridUrl = $this->
getUrl(
'adminhtml/order_shipment/getShippingItemsGrid', $urlParams);
96 $itemsPrice[
$item->getId()] =
$item->getPrice();
98 $itemsWeight[
$item->getId()] =
$item->getWeight();
99 $itemsProductId[
$item->getId()] =
$item->getProductId();
100 $itemsOrderItemId[
$item->getId()] =
$item->getOrderItemId();
104 $urlParams[
'order_id'] = $orderId;
105 $createLabelUrl = $this->
getUrl(
'adminhtml/order_shipment/save', $urlParams);
106 $itemsGridUrl = $this->
getUrl(
'adminhtml/order_shipment/getShippingItemsGrid', $urlParams);
109 $itemsQty[
$item->getOrderItemId()] =
$item->getQty() * 1;
110 $itemsPrice[
$item->getOrderItemId()] =
$item->getPrice();
111 $itemsName[
$item->getOrderItemId()] =
$item->getName();
112 $itemsWeight[
$item->getOrderItemId()] =
$item->getWeight();
113 $itemsProductId[
$item->getOrderItemId()] =
$item->getProductId();
114 $itemsOrderItemId[
$item->getOrderItemId()] =
$item->getOrderItemId();
119 'createLabelUrl' => $createLabelUrl,
120 'itemsGridUrl' => $itemsGridUrl,
121 'errorQtyOverLimit' =>
__(
122 'You are trying to add a quantity for some products that doesn\'t match the quantity that was shipped.' 124 'titleDisabledSaveBtn' =>
__(
'Products should be added to package(s)'),
125 'validationErrorMsg' =>
__(
'The value that you entered is not valid.'),
126 'shipmentItemsQty' => $itemsQty,
127 'shipmentItemsPrice' => $itemsPrice,
128 'shipmentItemsName' => $itemsName,
129 'shipmentItemsWeight' => $itemsWeight,
130 'shipmentItemsProductId' => $itemsProductId,
131 'shipmentItemsOrderItemId' => $itemsOrderItemId,
134 return $this->_jsonEncoder->encode(
$data);
147 $carrier = $this->_carrierFactory->create(
$order->getShippingMethod(
true)->getCarrierCode());
148 $countryShipper = $this->_scopeConfig->getValue(
149 \
Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID,
150 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE,
154 $params = new \Magento\Framework\DataObject(
156 'method' =>
$order->getShippingMethod(
true)->getMethod(),
157 'country_shipper' => $countryShipper,
158 'country_recipient' =>
$address->getCountryId(),
161 return $carrier->getContainerTypes(
$params);
174 $carrier = $this->_carrierFactory->create(
$order->getShippingMethod(
true)->getCarrierCode());
176 return $carrier->getCustomizableContainerTypes();
190 $carrier = $this->_carrierFactory->create(
$order->getShippingMethod(
true)->getCarrierCode());
192 $containerTypes = $carrier->getContainerTypes();
193 $containerType = !empty($containerTypes[
$code]) ? $containerTypes[
$code] :
'';
194 return $containerType;
207 $countryId = $this->
getShipment()->getOrder()->getShippingAddress()->getCountryId();
209 $carrier = $this->_carrierFactory->create(
$order->getShippingMethod(
true)->getCarrierCode());
211 $params = new \Magento\Framework\DataObject([
'country_recipient' => $countryId]);
212 $confirmationTypes = $carrier->getDeliveryConfirmationTypes(
$params);
213 $confirmationType = !empty($confirmationTypes[
$code]) ? $confirmationTypes[
$code] :
'';
214 return $confirmationType;
228 if (!empty($contentTypes[
$code])) {
229 return $contentTypes[
$code];
255 if ($itemsOf ==
'order' &&
$item->getOrderItemId() == $itemId) {
258 if ($itemsOf ==
'shipment' &&
$item->getId() == $itemId) {
263 return new \Magento\Framework\DataObject();
276 $shipperAddressCountryCode = $this->_scopeConfig->getValue(
277 \
Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID,
278 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE,
281 $recipientAddressCountryCode =
$address->getCountryId();
282 if ($shipperAddressCountryCode != $recipientAddressCountryCode) {
295 $countryId = $this->
getShipment()->getOrder()->getShippingAddress()->getCountryId();
297 $carrier = $this->_carrierFactory->create(
$order->getShippingMethod(
true)->getCarrierCode());
298 $params = new \Magento\Framework\DataObject([
'country_recipient' => $countryId]);
299 if ($carrier && is_array($carrier->getDeliveryConfirmationTypes(
$params))) {
300 return $carrier->getDeliveryConfirmationTypes(
$params);
313 return $this->
getUrl(
'adminhtml/order_shipment/printPackage',
$data);
324 $carrier = $this->_carrierFactory->create(
$order->getShippingMethod(
true)->getCarrierCode());
325 return $carrier->isGirthAllowed($this->
getShipment()->getOrder()->getShippingAddress()->getCountryId());
348 $carrier = $this->_carrierFactory->create(
$order->getShippingMethod(
true)->getCarrierCode());
349 $countryShipper = $this->_scopeConfig->getValue(
350 \
Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID,
351 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE,
355 $params = new \Magento\Framework\DataObject(
357 'method' =>
$order->getShippingMethod(
true)->getMethod(),
358 'country_shipper' => $countryShipper,
359 'country_recipient' =>
$address->getCountryId(),
362 return $carrier->getContentTypes(
$params);
375 return $orderInfo->getBaseCurrency()->getCurrencyCode();
398 return $orderInfo->getBaseCurrency()->formatTxt(
$price);
410 return $this->
getShipment()->getOrder()->getItemById($itemId)->getQtyOrdered() * 1;
getQtyOrderedItem($itemId)
displayCustomsPrice($price)
getContentTypeByCode($code)
getContainerTypeByCode($code)
getDeliveryConfirmationTypes()
getShipmentItem($itemId, $itemsOf)
getUrl($route='', $params=[])
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Shipping\Model\Carrier\Source\GenericInterface $sourceSizeModel, \Magento\Framework\Registry $coreRegistry, \Magento\Shipping\Model\CarrierFactory $carrierFactory, array $data=[])
getDeliveryConfirmationTypeByCode($code)
_getCustomizableContainers()
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
getCustomValueCurrencyCode()