Skip to content

Commit 55e63f3

Browse files
committed
Merge remote-tracking branch 'spank/multishipping-address-totals' into AC-8795
2 parents 2b3ad2e + 6e3f320 commit 55e63f3

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

app/code/Magento/OfflineShipping/Model/Carrier/Freeshipping.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,10 @@ public function collectRates(RateRequest $request)
136136
protected function _updateFreeMethodQuote($request)
137137
{
138138
$freeShipping = false;
139-
$items = $request->getAllItems();
140-
$c = count($items);
141-
for ($i = 0; $i < $c; $i++) {
142-
if ($items[$i]->getProduct() instanceof \Magento\Catalog\Model\Product) {
143-
if ($items[$i]->getFreeShipping()) {
139+
$items = $request->getAllItems() ?: [];
140+
foreach ($items as $item) {
141+
if ($item->getProduct() instanceof \Magento\Catalog\Model\Product) {
142+
if ($item->getFreeShipping()) {
144143
$freeShipping = true;
145144
} else {
146145
return;

app/code/Magento/Tax/Model/Sales/Total/Quote/Shipping.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function collect(
3838
return $this;
3939
}
4040

41+
$shippingAddress = $shippingAssignment->getShipping()->getAddress();
4142
$quoteDetails = $this->prepareQuoteDetails($shippingAssignment, [$shippingDataObject]);
4243
$taxDetails = $this->taxCalculationService
4344
->calculateTax($quoteDetails, $storeId);
@@ -48,10 +49,8 @@ public function collect(
4849
->calculateTax($baseQuoteDetails, $storeId);
4950
$baseTaxDetailsItems = $baseTaxDetails->getItems()[self::ITEM_CODE_SHIPPING];
5051

51-
$quote->getShippingAddress()
52-
->setShippingAmount($taxDetailsItems->getRowTotal());
53-
$quote->getShippingAddress()
54-
->setBaseShippingAmount($baseTaxDetailsItems->getRowTotal());
52+
$shippingAddress->setShippingAmount($taxDetailsItems->getRowTotal());
53+
$shippingAddress->setBaseShippingAmount($baseTaxDetailsItems->getRowTotal());
5554

5655
$this->processShippingTaxInfo(
5756
$shippingAssignment,
@@ -64,6 +63,8 @@ public function collect(
6463
}
6564

6665
/**
66+
* Fetch shipping including tax
67+
*
6768
* @param \Magento\Quote\Model\Quote $quote
6869
* @param Address\Total $total
6970
* @return array|null

app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/ShippingTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function testCollectDoesNotCalculateTaxIfThereIsNoItemsRelatedToGivenAddr
108108
{
109109
$storeId = 1;
110110
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($storeId);
111+
$this->quoteMock->expects($this->never())->method('getShippingAddress');
111112

112113
$addressMock = $this->getMockObject(Address::class, [
113114
'all_items' => [],
@@ -168,6 +169,7 @@ private function getMockObject($className, array $objectState)
168169

169170
public function testFetch()
170171
{
172+
$this->quoteMock->expects($this->never())->method('getShippingAddress');
171173
$value = 42;
172174
$total = new Total();
173175
$total->setShippingInclTax($value);
@@ -181,6 +183,8 @@ public function testFetch()
181183

182184
public function testFetchWithZeroShipping()
183185
{
186+
$this->quoteMock->expects($this->never())->method('getShippingAddress');
187+
184188
$value = 0;
185189
$total = new Total();
186190
$total->setShippingInclTax($value);

0 commit comments

Comments
 (0)