示例#1
0
文件: Cart.php 项目: margery/thelia
 /**
  *
  * Refresh article's price
  *
  * @param \Thelia\Model\Cart     $cart
  * @param \Thelia\Model\Currency $currency
  */
 public function updateCartPrices(CartModel $cart, CurrencyModel $currency)
 {
     $customer = $cart->getCustomer();
     $discount = 0;
     if (null !== $customer && $customer->getDiscount() > 0) {
         $discount = $customer->getDiscount();
     }
     // cart item
     foreach ($cart->getCartItems() as $cartItem) {
         $productSaleElements = $cartItem->getProductSaleElements();
         $productPrice = $productSaleElements->getPricesByCurrency($currency, $discount);
         $cartItem->setPrice($productPrice->getPrice())->setPromoPrice($productPrice->getPromoPrice());
         $cartItem->save();
     }
     // update the currency cart
     $cart->setCurrencyId($currency->getId());
     $cart->save();
 }