Skip to content

Commit

Permalink
MAGETWO-58334: [Github] Free shipping is not applied if cart price ru…
Browse files Browse the repository at this point in the history
…le match #6584
  • Loading branch information
Stanislav Idolov committed Oct 10, 2016
1 parent ad69430 commit 4204843
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ public function collect(

$addressWeight = $address->getWeight();
$freeMethodWeight = $address->getFreeMethodWeight();
$addressFreeShipping = $address->getFreeShipping();

$address->setFreeShipping(
$this->freeShipping->isFreeShipping($quote, $shippingAssignment->getItems())
);
$total->setTotalAmount($this->getCode(), 0);
$total->setBaseTotalAmount($this->getCode(), 0);

Expand Down Expand Up @@ -98,7 +96,7 @@ public function collect(
$itemQty = $child->getTotalQty();
$rowWeight = $itemWeight * $itemQty;
$addressWeight += $rowWeight;
if ($address->getFreeShipping() || $child->getFreeShipping() === true) {
if ($addressFreeShipping || $child->getFreeShipping() === true) {
$rowWeight = 0;
} elseif (is_numeric($child->getFreeShipping())) {
$freeQty = $child->getFreeShipping();
Expand All @@ -116,7 +114,7 @@ public function collect(
$itemWeight = $item->getWeight();
$rowWeight = $itemWeight * $item->getQty();
$addressWeight += $rowWeight;
if ($address->getFreeShipping() || $item->getFreeShipping() === true) {
if ($addressFreeShipping || $item->getFreeShipping() === true) {
$rowWeight = 0;
} elseif (is_numeric($item->getFreeShipping())) {
$freeQty = $item->getFreeShipping();
Expand All @@ -136,7 +134,7 @@ public function collect(
$itemWeight = $item->getWeight();
$rowWeight = $itemWeight * $item->getQty();
$addressWeight += $rowWeight;
if ($address->getFreeShipping() || $item->getFreeShipping() === true) {
if ($addressFreeShipping || $item->getFreeShipping() === true) {
$rowWeight = 0;
} elseif (is_numeric($item->getFreeShipping())) {
$freeQty = $item->getFreeShipping();
Expand All @@ -157,6 +155,10 @@ public function collect(

$address->setWeight($addressWeight);
$address->setFreeMethodWeight($freeMethodWeight);
$address->setFreeShipping(
$this->freeShipping->isFreeShipping($quote, $shippingAssignment->getItems())
);

$address->collectShippingRates();

if ($method) {
Expand Down

0 comments on commit 4204843

Please sign in to comment.