Пример #1
0
 /**
  * try to attach a new item to an existing cart
  *
  * @param EventDispatcherInterface $dispatcher
  * @param \Thelia\Model\Cart       $cart
  * @param int                      $productId
  * @param ProductSaleElements      $productSaleElements
  * @param float                    $quantity
  * @param ProductPriceTools        $productPrices
  *
  * @return CartItem
  */
 protected function doAddItem(EventDispatcherInterface $dispatcher, CartModel $cart, $productId, ProductSaleElements $productSaleElements, $quantity, ProductPriceTools $productPrices)
 {
     $cartItem = new CartItem();
     $cartItem->setDisptacher($dispatcher);
     $cartItem->setCart($cart)->setProductId($productId)->setProductSaleElementsId($productSaleElements->getId())->setQuantity($quantity)->setPrice($productPrices->getPrice())->setPromoPrice($productPrices->getPromoPrice())->setPromo($productSaleElements->getPromo())->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60 * 60 * 24 * 30))->save();
     return $cartItem;
 }