Example #1
0
 /**
  * @test
  */
 public function getTaxReturnsZeroIfNumberIsOutOfRange()
 {
     $minNumber = 5;
     $maxNumber = 10;
     $quantity = 4;
     $this->product = new \Extcode\Cart\Domain\Model\Cart\Product($this->productType, $this->productId, $this->tableId, $this->contentId, $this->sku, $this->title, $this->price, $this->taxClass, $quantity);
     $this->product->setMinNumberInCart($minNumber);
     $this->product->setMaxNumberInCart($maxNumber);
     $this->assertSame(0.0, $this->product->getTax());
     $quantity = 11;
     $this->product = new \Extcode\Cart\Domain\Model\Cart\Product($this->productType, $this->productId, $this->tableId, $this->contentId, $this->sku, $this->title, $this->price, $this->taxClass, $quantity);
     $this->product->setMinNumberInCart($minNumber);
     $this->product->setMaxNumberInCart($maxNumber);
     $this->assertSame(0.0, $this->product->getTax());
 }
Example #2
0
 /**
  * Add CartProduct to Order Item
  *
  * @param \Extcode\Cart\Domain\Model\Cart\Product $cartProduct
  *
  * @return void
  */
 protected function addProduct(\Extcode\Cart\Domain\Model\Cart\Product $cartProduct)
 {
     /**
      * @var \Extcode\Cart\Domain\Model\Order\Product $orderProduct
      */
     $orderProduct = new \Extcode\Cart\Domain\Model\Order\Product($cartProduct->getSku(), $cartProduct->getTitle(), $cartProduct->getQuantity());
     $orderProduct->setPid($this->storagePid);
     $orderProduct->setProductType($cartProduct->getProductType());
     $orderProduct->setPrice($cartProduct->getPrice());
     $orderProduct->setDiscount($cartProduct->getDiscount());
     $orderProduct->setGross($cartProduct->getGross());
     $orderProduct->setNet($cartProduct->getNet());
     $orderProduct->setTaxClass($this->taxClasses[$cartProduct->getTaxClass()->getId()]);
     $orderProduct->setTax($cartProduct->getTax());
     $additionalArray = $cartProduct->getAdditionalArray();
     $data = ['cartProduct' => $cartProduct, 'orderProduct' => &$orderProduct, 'additionalArray' => &$additionalArray, 'storagePid' => $this->storagePid];
     $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
     $signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'BeforeSetAdditionalData', [$data]);
     $orderProduct->setAdditionalData(json_encode($data['additionalArray']));
     $this->productRepository->add($orderProduct);
     $this->orderItem->addProduct($orderProduct);
     $this->addFeVariants($orderProduct, $cartProduct->getFeVariant());
 }
Example #3
0
 /**
  * @param \Extcode\Cart\Domain\Model\Cart\Product $product
  *
  * @param array $productVariantIds
  *
  * @return bool
  */
 public function removeproduct($product, $productVariantIds = null)
 {
     if (is_array($productVariantIds)) {
         $product->removeBeVariants($productVariantIds);
         if (!$product->getBeVariants()) {
             unset($this->products[$product->getId()]);
         }
         $this->calcAll();
     } else {
         $this->subCount($product->getQuantity());
         $this->subGross($product->getGross());
         $this->subNet($product->getNet());
         $this->subTax($product->getTax(), $product->getTaxClass());
         unset($this->products[$product->getId()]);
     }
     return true;
 }