Esempio n. 1
0
 /**
  * @param ItemInterface $item
  * @param OrderInterface $order
  * @param bool $deleteEntity
  */
 public function removeItem(ItemInterface $item, OrderInterface $order, $deleteEntity = true)
 {
     // Remove from order.
     $order->removeItem($item);
     if ($deleteEntity) {
         // Delete item.
         $this->em->remove($item);
     }
 }
Esempio n. 2
0
 /**
  * @param ApiOrderInterface|OrderInterface $order
  * @param bool $isOrderConfirmation
  *
  * @return string
  */
 public function getPdfName($order, $isOrderConfirmation = true)
 {
     if ($isOrderConfirmation) {
         return $this->namePrefixConfirmedOrder . $order->getNumber() . '.pdf';
     }
     return $this->namePrefixDynamicOrder . $order->getNumber() . '.pdf';
 }
Esempio n. 3
0
 /**
  * Removes items from cart that have no valid shop products
  * applied; and returns if all products are still available
  *
  * @param OrderInterface $cart
  *
  * @return bool If all products are available
  */
 private function checkProductsAvailability(OrderInterface $cart)
 {
     // no check needed
     if ($cart->getItems()->isEmpty()) {
         return true;
     }
     $containsInvalidProducts = false;
     /** @var \Sulu\Bundle\Sales\CoreBundle\Entity\ItemInterface $item */
     foreach ($cart->getItems() as $item) {
         if (!$item->getProduct() || !$item->getProduct()->isValidShopProduct($this->defaultCurrency)) {
             $containsInvalidProducts = true;
             $cart->removeItem($item);
             $this->em->remove($item);
         }
     }
     // persist new cart
     if ($containsInvalidProducts) {
         $this->em->flush();
     }
     return !$containsInvalidProducts;
 }