Example #1
0
 public function saveCartProducts(Cart $cart)
 {
     if (!$this->order_srl) {
         throw new ShopException('Order not persisted');
     }
     if (!$cart->cart_srl) {
         throw new ShopException('Cart not persisted');
     }
     //remove all already existing links
     $this->repo->deleteOrderProducts($this->order_srl);
     //set the new links
     /** @var $cart_product SimpleProduct */
     $cart_products = $cart->getProducts();
     foreach ($cart_products as $cart_product) {
         if ($cart_product->available && $cart_product->product_srl) {
             $this->repo->insertOrderProduct($this->order_srl, $cart_product);
         }
     }
 }