Skip to content

Commit 975872e

Browse files
committed
MAGETWO-98680: Cart Price Rule code is absent on "view Order/Invoice" Admin page if had been used for Free Shipping
1 parent 06f3ed4 commit 975872e

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

app/code/Magento/Sales/Block/Adminhtml/Totals.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/**
1111
* Adminhtml sales totals block
12-
*
13-
* @package Magento\Sales\Block\Adminhtml
1412
*/
1513
class Totals extends \Magento\Sales\Block\Order\Totals
1614
{
@@ -75,7 +73,7 @@ protected function _initTotals()
7573
$this->getSource()->getShippingDescription())
7674
) {
7775
$shippingLabel = __('Shipping & Handling');
78-
if ($this->isHasFreeShipping($this->getOrder()) && $this->getSource()->getDiscountDescription()) {
76+
if ($this->isFreeShipping($this->getOrder()) && $this->getSource()->getDiscountDescription()) {
7977
$shippingLabel .= sprintf(' (%s)', $this->getSource()->getDiscountDescription());
8078
}
8179
$this->_totals['shipping'] = new \Magento\Framework\DataObject(
@@ -127,16 +125,16 @@ protected function _initTotals()
127125
* @param Order $order
128126
* @return bool
129127
*/
130-
private function isHasFreeShipping(Order $order): bool
128+
private function isFreeShipping(Order $order): bool
131129
{
132-
$isActive = false;
130+
$isFreeShipping = false;
133131
foreach ($order->getItems() as $orderItem) {
134-
if ($orderItem->getFreeShipping() === '1') {
135-
$isActive = true;
132+
if ($orderItem->getFreeShipping() == '1') {
133+
$isFreeShipping = true;
136134
break;
137135
}
138136
}
139137

140-
return $isActive;
138+
return $isFreeShipping;
141139
}
142140
}

dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/TotalsTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Sales\Block\Adminhtml;
79

810
use Magento\Framework\View\LayoutInterface;
@@ -15,10 +17,10 @@
1517
class TotalsTest extends \Magento\TestFramework\TestCase\AbstractBackendController
1618
{
1719
/** @var LayoutInterface */
18-
protected $_layout;
20+
private $layout;
1921

2022
/** @var Totals */
21-
protected $_block;
23+
private $block;
2224

2325
/** @var OrderFactory */
2426
private $orderFactory;
@@ -29,8 +31,8 @@ class TotalsTest extends \Magento\TestFramework\TestCase\AbstractBackendControll
2931
protected function setUp()
3032
{
3133
parent::setUp();
32-
$this->_layout = $this->_objectManager->get(LayoutInterface::class);
33-
$this->_block = $this->_layout->createBlock(Totals::class, 'totals_block');
34+
$this->layout = $this->_objectManager->get(LayoutInterface::class);
35+
$this->block = $this->layout->createBlock(Totals::class, 'totals_block');
3436
$this->orderFactory = $this->_objectManager->get(OrderFactory::class);
3537
}
3638

@@ -43,10 +45,10 @@ public function testShowShippingCoupon()
4345
$order = $this->orderFactory->create();
4446
$order->loadByIncrementId('100000001');
4547

46-
$this->_block->setOrder($order);
47-
$this->_block->toHtml();
48+
$this->block->setOrder($order);
49+
$this->block->toHtml();
4850

49-
$shippingTotal = $this->_block->getTotal('shipping');
51+
$shippingTotal = $this->block->getTotal('shipping');
5052
$this->assertNotFalse($shippingTotal, 'Shipping method is absent on the total\'s block.');
5153
$this->assertContains(
5254
'1234567890',

dev/tests/integration/testsuite/Magento/Sales/_files/order_with_free_shipping_by_coupon.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
use Magento\Sales\Api\OrderRepositoryInterface;
89
use Magento\Sales\Model\Order;

0 commit comments

Comments
 (0)