Skip to content

Commit 4204843

Browse files
author
Stanislav Idolov
committed
MAGETWO-58334: [Github] Free shipping is not applied if cart price rule match #6584
1 parent ad69430 commit 4204843

File tree

1 file changed

+8
-6
lines changed
  • app/code/Magento/Quote/Model/Quote/Address/Total

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ public function collect(
5959

6060
$addressWeight = $address->getWeight();
6161
$freeMethodWeight = $address->getFreeMethodWeight();
62+
$addressFreeShipping = $address->getFreeShipping();
6263

63-
$address->setFreeShipping(
64-
$this->freeShipping->isFreeShipping($quote, $shippingAssignment->getItems())
65-
);
6664
$total->setTotalAmount($this->getCode(), 0);
6765
$total->setBaseTotalAmount($this->getCode(), 0);
6866

@@ -98,7 +96,7 @@ public function collect(
9896
$itemQty = $child->getTotalQty();
9997
$rowWeight = $itemWeight * $itemQty;
10098
$addressWeight += $rowWeight;
101-
if ($address->getFreeShipping() || $child->getFreeShipping() === true) {
99+
if ($addressFreeShipping || $child->getFreeShipping() === true) {
102100
$rowWeight = 0;
103101
} elseif (is_numeric($child->getFreeShipping())) {
104102
$freeQty = $child->getFreeShipping();
@@ -116,7 +114,7 @@ public function collect(
116114
$itemWeight = $item->getWeight();
117115
$rowWeight = $itemWeight * $item->getQty();
118116
$addressWeight += $rowWeight;
119-
if ($address->getFreeShipping() || $item->getFreeShipping() === true) {
117+
if ($addressFreeShipping || $item->getFreeShipping() === true) {
120118
$rowWeight = 0;
121119
} elseif (is_numeric($item->getFreeShipping())) {
122120
$freeQty = $item->getFreeShipping();
@@ -136,7 +134,7 @@ public function collect(
136134
$itemWeight = $item->getWeight();
137135
$rowWeight = $itemWeight * $item->getQty();
138136
$addressWeight += $rowWeight;
139-
if ($address->getFreeShipping() || $item->getFreeShipping() === true) {
137+
if ($addressFreeShipping || $item->getFreeShipping() === true) {
140138
$rowWeight = 0;
141139
} elseif (is_numeric($item->getFreeShipping())) {
142140
$freeQty = $item->getFreeShipping();
@@ -157,6 +155,10 @@ public function collect(
157155

158156
$address->setWeight($addressWeight);
159157
$address->setFreeMethodWeight($freeMethodWeight);
158+
$address->setFreeShipping(
159+
$this->freeShipping->isFreeShipping($quote, $shippingAssignment->getItems())
160+
);
161+
160162
$address->collectShippingRates();
161163

162164
if ($method) {

0 commit comments

Comments
 (0)