Skip to content

Commit 3c4cb60

Browse files
YevSentomiroshnichenko
authored andcommitted
MAGETWO-86525: [2.2.x] Remove USPS shipping label creation (USPS API removal 2/23/18)
- Removed an ability to create shipping labels with USPS method according to API changes - Updated shipping label buttons handlers to support printing existing labels
1 parent 0e44549 commit 3c4cb60

File tree

2 files changed

+54
-34
lines changed

2 files changed

+54
-34
lines changed

app/code/Magento/Shipping/view/adminhtml/templates/view/form.phtml

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,71 +5,76 @@
55
*/
66

77
// @codingStandardsIgnoreFile
8-
8+
/**
9+
* @var \Magento\Shipping\Block\Adminhtml\View\Form $block
10+
*/
11+
$order = $block->getShipment()->getOrder();
912
?>
10-
<?php $_order = $block->getShipment()->getOrder() ?>
11-
<?= $block->getChildHtml('order_info') ?>
13+
<?= $block->getChildHtml('order_info'); ?>
1214
<section class="admin__page-section order-shipment-billing-shipping">
1315
<div class="admin__page-section-title">
14-
<span class="title"><?= /* @escapeNotVerified */ __('Payment &amp; Shipping Method') ?></span>
16+
<span class="title"><?= $block->escapeHtml(__('Payment &amp; Shipping Method')); ?></span>
1517
</div>
1618
<div class="admin__page-section-content">
17-
18-
<?php /* Billing Address */ ?>
1919
<div class="admin__page-section-item order-payment-method">
2020
<div class="admin__page-section-item-title">
21-
<span class="title"><?= /* @escapeNotVerified */ __('Payment Information') ?></span>
21+
<span class="title"><?= $block->escapeHtml(__('Payment Information')); ?></span>
2222
</div>
2323
<div class="admin__page-section-item-content">
2424
<div><?= $block->getChildHtml('order_payment') ?></div>
25-
<div class="order-payment-currency"><?= /* @escapeNotVerified */ __('The order was placed using %1.', $_order->getOrderCurrencyCode()) ?></div>
25+
<div class="order-payment-currency">
26+
<?= $block->escapeHtml(__('The order was placed using %1.', $order->getOrderCurrencyCode())); ?>
27+
</div>
2628
</div>
2729
</div>
2830

29-
<?php /* Shipping Address */ ?>
3031
<div class="admin__page-section-item order-shipping-address">
3132
<div class="admin__page-section-item-title">
32-
<span class="title"><?= /* @escapeNotVerified */ __('Shipping and Tracking Information') ?></span>
33+
<span class="title"><?= $block->escapeHtml(__('Shipping and Tracking Information')); ?></span>
3334
</div>
3435
<div class="admin__page-section-item-content">
3536
<div class="shipping-description-wrapper">
3637
<?php if ($block->getShipment()->getTracksCollection()->count()): ?>
3738
<p>
38-
<a href="#" id="linkId" onclick="popWin('<?= /* @escapeNotVerified */ $this->helper('Magento\Shipping\Helper\Data')->getTrackingPopupUrlBySalesModel($block->getShipment()) ?>','trackshipment','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?= /* @escapeNotVerified */ __('Track this shipment') ?>"><?= /* @escapeNotVerified */ __('Track this shipment') ?></a>
39+
<a href="#" id="linkId" onclick="popWin('<?= $block->escapeUrl($this->helper('Magento\Shipping\Helper\Data')->getTrackingPopupUrlBySalesModel($block->getShipment())); ?>','trackshipment','width=800,height=600,resizable=yes,scrollbars=yes')"
40+
title="<?= $block->escapeHtml(__('Track this shipment')); ?>">
41+
<?= $block->escapeHtml(__('Track this shipment')); ?>
42+
</a>
3943
</p>
4044
<?php endif; ?>
4145
<div class="shipping-description-title">
42-
<?= $block->escapeHtml($_order->getShippingDescription()) ?>
46+
<?= $block->escapeHtml($order->getShippingDescription()); ?>
4347
</div>
4448

45-
<?= /* @escapeNotVerified */ __('Total Shipping Charges') ?>:
49+
<?= $block->escapeHtml(__('Total Shipping Charges')); ?>:
4650

4751
<?php if ($this->helper('Magento\Tax\Helper\Data')->displayShippingPriceIncludingTax()): ?>
48-
<?php $_excl = $block->displayShippingPriceInclTax($_order); ?>
52+
<?php $excl = $block->displayShippingPriceInclTax($order); ?>
4953
<?php else: ?>
50-
<?php $_excl = $block->displayPriceAttribute('shipping_amount', false, ' '); ?>
54+
<?php $excl = $block->displayPriceAttribute('shipping_amount', false, ' '); ?>
5155
<?php endif; ?>
52-
<?php $_incl = $block->displayShippingPriceInclTax($_order); ?>
56+
<?php $incl = $block->displayShippingPriceInclTax($order); ?>
5357

54-
<?= /* @escapeNotVerified */ $_excl ?>
55-
<?php if ($this->helper('Magento\Tax\Helper\Data')->displayShippingBothPrices() && $_incl != $_excl): ?>
56-
(<?= /* @escapeNotVerified */ __('Incl. Tax') ?> <?= /* @escapeNotVerified */ $_incl ?>)
58+
<?= /* @noEscape */ $excl; ?>
59+
<?php if ($this->helper('Magento\Tax\Helper\Data')->displayShippingBothPrices() && $incl != $excl): ?>
60+
(<?= $block->escapeHtml(__('Incl. Tax')); ?> <?= /* @noEscape */ $incl; ?>)
5761
<?php endif; ?>
5862
</div>
59-
<?php if ($block->canCreateShippingLabel()): ?>
63+
6064
<p>
61-
<?= /* @escapeNotVerified */ $block->getCreateLabelButton() ?>
65+
<?php if ($block->canCreateShippingLabel()): ?>
66+
<?= /* @noEscape */ $block->getCreateLabelButton(); ?>
67+
<?php endif ?>
6268
<?php if ($block->getShipment()->getShippingLabel()): ?>
63-
<?= /* @escapeNotVerified */ $block->getPrintLabelButton() ?>
69+
<?= /* @noEscape */ $block->getPrintLabelButton(); ?>
6470
<?php endif ?>
6571
<?php if ($block->getShipment()->getPackages()): ?>
66-
<?= /* @escapeNotVerified */ $block->getShowPackagesButton() ?>
72+
<?= /* @noEscape */ $block->getShowPackagesButton(); ?>
6773
<?php endif ?>
6874
</p>
69-
<?php endif ?>
70-
<?= $block->getChildHtml('shipment_tracking') ?>
75+
<?= $block->getChildHtml('shipment_tracking'); ?>
7176

72-
<?= $block->getChildHtml('shipment_packaging') ?>
77+
<?= $block->getChildHtml('shipment_packaging'); ?>
7378
<script>
7479
require([
7580
'jquery',
@@ -80,9 +85,9 @@
8085
window.packaging.sendCreateLabelRequest();
8186
});
8287
window.packaging.setLabelCreatedCallback(function () {
83-
setLocation("<?php /* @escapeNotVerified */ echo $block->getUrl(
88+
setLocation("<?php echo $block->escapeUrl($block->getUrl(
8489
'adminhtml/order_shipment/view',
85-
['shipment_id' => $block->getShipment()->getId()]
90+
['shipment_id' => $block->getShipment()->getId()])
8691
); ?>");
8792
});
8893
};
@@ -101,23 +106,23 @@
101106

102107
<section class="admin__page-section">
103108
<div class="admin__page-section-title">
104-
<span class="title"><?= /* @escapeNotVerified */ __('Items Shipped') ?></span>
109+
<span class="title"><?= $block->escapeHtml(__('Items Shipped')); ?></span>
105110
</div>
106-
<?= $block->getChildHtml('shipment_items') ?>
111+
<?= $block->getChildHtml('shipment_items'); ?>
107112
</section>
108113

109114
<section class="admin__page-section">
110115
<div class="admin__page-section-title">
111-
<span class="title"><?= /* @escapeNotVerified */ __('Order Total') ?></span>
116+
<span class="title"><?= $block->escapeHtml(__('Order Total')); ?></span>
112117
</div>
113118
<div class="admin__page-section-content">
114-
<?= $block->getChildHtml('shipment_packed') ?>
119+
<?= $block->getChildHtml('shipment_packed'); ?>
115120

116121
<div class="admin__page-section-item order-comments-history">
117122
<div class="admin__page-section-item-title">
118-
<span class="title"><?= /* @escapeNotVerified */ __('Shipment History') ?></span>
123+
<span class="title"><?= $block->escapeHtml(__('Shipment History')); ?></span>
119124
</div>
120-
<div class="admin__page-section-item-content"><?= $block->getChildHtml('order_comments') ?></div>
125+
<div class="admin__page-section-item-content"><?= $block->getChildHtml('order_comments'); ?></div>
121126
</div>
122127
</div>
123128
</section>

app/code/Magento/Usps/Model/Carrier.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,15 @@ public function getResult()
364364
return $this->_result;
365365
}
366366

367+
/**
368+
* @inheritdoc
369+
* Starting from 23.02.2018 USPS doesn't allow to create free shipping labels via their API.
370+
*/
371+
public function isShippingLabelsAvailable()
372+
{
373+
return false;
374+
}
375+
367376
/**
368377
* Get quotes
369378
*
@@ -1423,6 +1432,8 @@ protected function _filterServiceName($name)
14231432
*
14241433
* @param \Magento\Framework\DataObject $request
14251434
* @return string
1435+
* @deprecated This method should not be used anymore.
1436+
* @see \Magento\Usps\Model\Carrier::_doShipmentRequest method doc block.
14261437
*/
14271438
protected function _formUsExpressShipmentRequest(\Magento\Framework\DataObject $request)
14281439
{
@@ -1598,6 +1609,8 @@ protected function _convertPoundOunces($weightInPounds)
15981609
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
15991610
* @SuppressWarnings(PHPMD.NPathComplexity)
16001611
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1612+
* @deprecated Should not be used anymore.
1613+
* @see \Magento\Usps\Model\Carrier::_doShipmentRequest doc block.
16011614
*/
16021615
protected function _formIntlShipmentRequest(\Magento\Framework\DataObject $request)
16031616
{
@@ -1851,6 +1864,8 @@ protected function _formIntlShipmentRequest(\Magento\Framework\DataObject $reque
18511864
* @param \Magento\Framework\DataObject $request
18521865
* @return \Magento\Framework\DataObject
18531866
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
1867+
* @deprecated This method must not be used anymore. Starting from 23.02.2018 USPS elimates API usage for
1868+
* free shipping labels generating.
18541869
*/
18551870
protected function _doShipmentRequest(\Magento\Framework\DataObject $request)
18561871
{

0 commit comments

Comments
 (0)