Skip to content

Commit

Permalink
CartCalculator::updatePositions fixed getting position ID
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Feb 2, 2016
1 parent 0046d4a commit acb92e9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cart/CartCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ private function sendRequest($data)
*/
private function updatePositions($data)
{
foreach ($this->cart->positions as $id => $position) {
foreach ($this->cart->positions as $position) {
$id = $position->id;
if (isset($data[$id])) {
$value = reset($data[$id]['value']); // data is wrapped with currency. todo: dynamic currencies
$position->setPrice($value['price']);
$position->setValue($value['value']);
} else {
Yii::warning('Cart position was removed from the cart because of failed value calculation', 'hipanel.cart');
Yii::error('Cart position was removed from the cart because of failed value calculation. Normally this should never happen.', 'hipanel.cart');
$this->cart->removeById($position->id);
break;
}
Expand All @@ -134,4 +135,4 @@ protected function getCalculationModels()

return $models;
}
}
}

0 comments on commit acb92e9

Please sign in to comment.