Skip to content

Commit

Permalink
Added ShoppingCart::hasErrors() method
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Mar 21, 2016
1 parent a1afb99 commit 808461d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ShoppingCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,19 @@ public function formatCurrency($sum, $currency = null)
{
return Yii::$app->formatter->format($sum, ['currency', $currency ?: $this->currency]);
}

/**
* Checks whether any of cart positions has error in `id` attribute
* @return boolean
*/
public function hasErrors()
{
foreach ($this->_positions as $position) {
if ($position->hasErrors('id')) {
return true;
}
}

return false;
}
}

0 comments on commit 808461d

Please sign in to comment.