Skip to content

Commit daf845a

Browse files
author
Oleksandr Karpenko
committed
MAGETWO-44268: Shipping & Handling is not updated during creating order from admin
1 parent 1260725 commit daf845a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ public function collect(
169169
);
170170
$total->setTotalAmount($this->getCode(), $amountPrice);
171171
$total->setBaseTotalAmount($this->getCode(), $rate->getPrice());
172-
$total->setShippingAmount($address->getShippingAmount());
173172
$shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
174173
$address->setShippingDescription(trim($shippingDescription, ' -'));
174+
$total->setShippingAmount($rate->getPrice());
175+
$total->setShippingDescription($address->getShippingDescription());
175176
break;
176177
}
177178
}
@@ -185,6 +186,7 @@ public function collect(
185186
* @param \Magento\Quote\Model\Quote $quote
186187
* @param \Magento\Quote\Model\Quote\Address\Total $total
187188
* @return array
189+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
188190
*/
189191
public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
190192
{

app/code/Magento/Quote/Model/Quote/TotalsCollector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public function collect(\Magento\Quote\Model\Quote $quote)
145145

146146
$total->setShippingAmount($addressTotal->getShippingAmount());
147147
$total->setBaseShippingAmount($addressTotal->getBaseShippingAmount());
148+
$total->setShippingDescription($addressTotal->getShippingDescription());
148149

149150
$total->setSubtotal((float)$total->getSubtotal() + $addressTotal->getSubtotal());
150151
$total->setBaseSubtotal((float)$total->getBaseSubtotal() + $addressTotal->getBaseSubtotal());

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ protected function setUp()
7272
'setShippingAmount',
7373
'setBaseTotalAmount',
7474
'setTotalAmount',
75+
'setShippingDescription',
7576
],
7677
[],
7778
'',
@@ -94,8 +95,8 @@ protected function setUp()
9495
'setItemQty',
9596
'collectShippingRates',
9697
'getAllShippingRates',
97-
'getShippingAmount',
9898
'setShippingDescription',
99+
'getShippingDescription',
99100
'getFreeShipping',
100101
],
101102
[],
@@ -229,9 +230,6 @@ public function testCollect()
229230
->method('convert')
230231
->with(5, $this->store)
231232
->willReturn(5);
232-
$this->address->expects($this->once())
233-
->method('getShippingAmount')
234-
->willReturn(5);
235233
$this->total->expects($this->once())
236234
->method('setShippingAmount')
237235
->with(5);
@@ -244,6 +242,12 @@ public function testCollect()
244242
$this->address->expects($this->once())
245243
->method('setShippingDescription')
246244
->with('Carrier title - Method title');
245+
$this->address->expects($this->once())
246+
->method('getShippingDescription')
247+
->willReturn('Carrier title - Method title');
248+
$this->total->expects($this->once())
249+
->method('setShippingDescription')
250+
->with('Carrier title - Method title');
247251

248252
$this->shippingModel->collect($this->quote, $this->shippingAssignment, $this->total);
249253
}

0 commit comments

Comments
 (0)