Ejemplo n.º 1
0
 public function modifyQuantity(\Club\ShopBundle\Entity\CartProduct $product, $quantity = 1)
 {
     if (!($product->getQuantity() + $quantity)) {
         $this->em->remove($product);
     } else {
         $product->setQuantity($product->getQuantity() + $quantity);
     }
     $this->cart->setPrice($this->cart->getPrice() + $product->getPrice() * $quantity);
     $this->cart->setVatPrice($this->cart->getVatPrice() + $product->getVatPrice() * $quantity);
     $this->save();
     return $product;
 }
Ejemplo n.º 2
0
 public function addSimpleProduct(\Club\ShopBundle\Entity\CartProduct $product)
 {
     // will not add product attribute
     $prod = new \Club\ShopBundle\Entity\OrderProduct();
     $prod->setOrder($this->order);
     $prod->setPrice($product->getPrice());
     $prod->setQuantity($product->getQuantity());
     $prod->setProductName($product->getProductName());
     $prod->setType($product->getType());
     $this->order->addOrderProduct($prod);
     $this->em->persist($prod);
 }