Skip to content

Bugfix/shipping rates result incorrect cost value #35202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: 2.4-develop
Choose a base branch
from
1 change: 1 addition & 0 deletions app/code/Magento/Shipping/Model/Rate/PackageResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function getAllRates()
throw new \InvalidArgumentException('Same object received from carrier.');
}
$rate->setPrice($rate->getPrice() + $currentRate->getPrice());
$rate->setCost($rate->getCost() + $currentRate->getCost());
continue 2;
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Shipping/Model/Rate/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ public function asArray()
'title' => $rate->getMethodTitle(),
'price' => $rate->getPrice(),
'price_formatted' => $currencyFilter->filter($rate->getPrice()),
'cost' => $rate->getCost(),
'cost_formatted' => $currencyFilter->filter($rate->getCost()),
];
}
return $rates;
Expand Down Expand Up @@ -224,6 +226,7 @@ public function updateRatePrice($packageCount)
if ($packageCount > 1) {
foreach ($this->_rates as $rate) {
$rate->setPrice($rate->getPrice() * $packageCount);
$rate->setCost($rate->getCost() * $packageCount);
}
}

Expand Down