Skip to content

Commit 2609b52

Browse files
committed
Merge remote-tracking branch 'magento-l3/ACP2E-2515' into Tier4-Kings-PR-12-18-2023
2 parents 59b2921 + 8bfadcc commit 2609b52

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function collectRates(RateRequest $request)
132132
if ($item->getHasChildren() && $item->isShipSeparately()) {
133133
foreach ($item->getChildren() as $child) {
134134
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
135-
$freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
135+
$freeShipping = (int)$child->getFreeShipping();
136136
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
137137
}
138138
}

app/code/Magento/OfflineShipping/Test/Unit/Model/Carrier/TablerateTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ protected function setUp(): void
118118

119119
/**
120120
* @param bool $freeshipping
121+
* @param bool $isShipSeparately
121122
* @dataProvider collectRatesWithGlobalFreeShippingDataProvider
122123
* @return void
123124
*/
124-
public function testCollectRatesWithGlobalFreeShipping($freeshipping)
125+
public function testCollectRatesWithGlobalFreeShipping($freeshipping, $isShipSeparately)
125126
{
126127
$rate = [
127128
'price' => 15,
@@ -177,11 +178,17 @@ public function testCollectRatesWithGlobalFreeShipping($freeshipping)
177178
$this->resultFactoryMock->expects($this->once())->method('create')->willReturn($result);
178179

179180
$product->expects($this->any())->method('isVirtual')->willReturn(false);
180-
181181
$item->expects($this->any())->method('getProduct')->willReturn($product);
182-
$item->expects($this->any())->method('getFreeShipping')->willReturn(1);
183182
$item->expects($this->any())->method('getQty')->willReturn(1);
184-
183+
if ($isShipSeparately) {
184+
$freeShippingReturnValue = true;
185+
$item->expects($this->any())->method('getHasChildren')->willReturn(1);
186+
$item->expects($this->any())->method('isShipSeparately')->willReturn(1);
187+
$item->expects($this->any())->method('getChildren')->willReturn([$item]);
188+
} else {
189+
$freeShippingReturnValue = "1";
190+
}
191+
$item->expects($this->any())->method('getFreeShipping')->willReturn($freeShippingReturnValue);
185192
$request->expects($this->any())->method('getAllItems')->willReturn([$item]);
186193
$request->expects($this->any())->method('getPackageQty')->willReturn(1);
187194

@@ -225,8 +232,9 @@ private function captureArg(&$captureVar)
225232
public function collectRatesWithGlobalFreeShippingDataProvider()
226233
{
227234
return [
228-
['freeshipping' => true],
229-
['freeshipping' => false]
235+
['freeshipping' => true, 'isShipSeparately' => false],
236+
['freeshipping' => false, 'isShipSeparately' => false],
237+
['freeshipping' => true, 'isShipSeparately' => true]
230238
];
231239
}
232240
}

0 commit comments

Comments
 (0)