/** * {@inheritdoc} */ public function createItem(CartItem $CartItem) { $class = $this->getClass(); $item = new $class(); $title = $CartItem->getProductSet()->getProduct()->getTitle(); if ($CartItem->getProductSet()->getProductSize()) { $title .= ' ' . $CartItem->getProductSet()->getProductSize()->getTitle(); } if ($CartItem->getProductSet()->getProductOption()) { $title .= '/' . $CartItem->getProductSet()->getProductOption()->getTitle(); } $item->setTitle($title); $item->setProductSet($CartItem->getProductSet()); $item->setPrice($CartItem->getProductSet()->getProduct()->getStorePrice()); $item->setQuantity($CartItem->getQuantity()); return $item; }
/** * Add cart_items * * @param Chewbacca\CartBundle\Entity\CartItem $cartItems */ public function addCartItem(\Chewbacca\CartBundle\Entity\CartItem $cartItem) { $this->cart_items[] = $cartItem; $cartItem->setCart($this); }
public function equals(CartItem $item) { return $this->getProductSet()->getId() === $item->getProductSet()->getId(); }