Example #1
0
 /**
  * {@inheritdoc}
  */
 public function calculatePrice(CartInterface $cart)
 {
     $price = 0;
     $finalPrice = 0;
     foreach ($cart->getItems() as $item) {
         $price = bcadd($price, $item->getPrice(), 2);
         $finalPrice = bcadd($finalPrice, $item->getFinalPrice(), 2);
     }
     $cart->setPrice($price);
     $cart->setFinalPrice($finalPrice);
     return $cart;
 }
Example #2
0
 /**
  * Remove all cart items of the given cart and apply a transition
  * from current state to TRANSITION_DELETE.
  *
  * @param CartInterface $cart
  *
  * @return CartInterface
  * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
  */
 public function deleteAllItems(CartInterface $cart)
 {
     foreach ($cart->getItems() as $item) {
         $this->doDeleteItem($cart, $item);
     }
     return $cart;
 }