/**
  * @return void
  */
 public function testPluginExpandsCartItemWithExpectedProductData()
 {
     $localeName = Store::getInstance()->getCurrentLocale();
     $localeTransfer = $this->localeFacade->getLocale($localeName);
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(self::TAX_RATE_PERCENTAGE)->setName(self::TAX_RATE_NAME);
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->addSpyTaxRate($taxRateEntity)->setName(self::TAX_SET_NAME);
     $productAbstractEntity = new SpyProductAbstract();
     $productAbstractEntity->setSpyTaxSet($taxSetEntity)->setAttributes('')->setSku(self::SKU_PRODUCT_ABSTRACT);
     $localizedAttributesEntity = new SpyProductLocalizedAttributes();
     $localizedAttributesEntity->setName(self::PRODUCT_CONCRETE_NAME)->setAttributes('')->setFkLocale($localeTransfer->getIdLocale());
     $productConcreteEntity = new SpyProduct();
     $productConcreteEntity->setSpyProductAbstract($productAbstractEntity)->setAttributes('')->addSpyProductLocalizedAttributes($localizedAttributesEntity)->setSku(self::SKU_PRODUCT_CONCRETE)->save();
     $changeTransfer = new CartChangeTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku(self::SKU_PRODUCT_CONCRETE);
     $changeTransfer->addItem($itemTransfer);
     $this->productCartConnectorFacade->expandItems($changeTransfer);
     $expandedItemTransfer = $changeTransfer->getItems()[0];
     $this->assertEquals(self::SKU_PRODUCT_ABSTRACT, $expandedItemTransfer->getAbstractSku());
     $this->assertEquals(self::SKU_PRODUCT_CONCRETE, $expandedItemTransfer->getSku());
     $this->assertEquals($productAbstractEntity->getIdProductAbstract(), $expandedItemTransfer->getIdProductAbstract());
     $this->assertEquals($productConcreteEntity->getIdProduct(), $expandedItemTransfer->getId());
 }
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer
  *
  * @return void
  */
 protected function setProductOptionSumGrossPrice(ItemTransfer $itemTransfer)
 {
     foreach ($itemTransfer->getProductOptions() as $productOptionTransfer) {
         $this->assertProductOptionRequirements($productOptionTransfer);
         $productOptionTransfer->setSumGrossPrice($productOptionTransfer->getUnitGrossPrice() * $productOptionTransfer->getQuantity());
     }
 }
Beispiel #3
0
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $cartItem
  *
  * @return string
  */
 protected function buildGroupKey(ItemTransfer $cartItem)
 {
     $groupKey = $cartItem->getGroupKey();
     if (empty($groupKey)) {
         return $cartItem->getSku();
     }
     return $groupKey;
 }
Beispiel #4
0
 /**
  * @param int $price
  * @param int $quantity
  * @param string $sku
  *
  * @return \Generated\Shared\Transfer\ItemTransfer
  */
 protected function createItemTransfer($price = 0, $quantity = 0, $sku = '')
 {
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setUnitGrossPrice($price);
     $itemTransfer->setQuantity($quantity);
     $itemTransfer->setSku($sku);
     return $itemTransfer;
 }
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $salesOrderItems
  *
  * @return bool
  */
 protected function shouldItemRefunded(ItemTransfer $itemTransfer, array $salesOrderItems)
 {
     foreach ($salesOrderItems as $salesOrderItem) {
         if ($salesOrderItem->getIdSalesOrderItem() === $itemTransfer->getIdSalesOrderItem()) {
             return true;
         }
     }
     return false;
 }
Beispiel #6
0
 /**
  * @param array $grossPrices
  *
  * @return \Generated\Shared\Transfer\ItemTransfer[]
  */
 protected function getItems(array $grossPrices)
 {
     $items = [];
     foreach ($grossPrices as $grossPrice) {
         $item = new ItemTransfer();
         $item->setUnitGrossPrice($grossPrice);
         $items[] = $item;
     }
     return $items;
 }
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $cartItem
  *
  * @throws \RuntimeException
  *
  * @return void
  */
 public function expandProductOptionTransfers(ItemTransfer $cartItem)
 {
     foreach ($cartItem->getProductOptions() as &$productOptionTransfer) {
         if ($productOptionTransfer->getIdOptionValueUsage() === null || $productOptionTransfer->getLocaleCode() === null) {
             throw new \RuntimeException('Unable to expand product option. Missing required values: idOptionValueUsage, localeCode');
         }
         $productOptionTransfer = $this->productOptionFacade->getProductOption($productOptionTransfer->getIdOptionValueUsage(), $productOptionTransfer->getLocaleCode());
         $productOptionTransfer->setQuantity($cartItem->getQuantity());
     }
 }
Beispiel #8
0
 /**
  * @return void
  */
 public function testExpandItemMustNotChangeGroupKeyWhenGroupKeyIsSet()
 {
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku(self::SKU);
     $itemTransfer->setGroupKey(self::SKU);
     $changeTransfer = new CartChangeTransfer();
     $changeTransfer->addItem($itemTransfer);
     $plugin = new SkuGroupKeyPlugin(new Factory('Cart'), Locator::getInstance());
     $plugin->expandItems($changeTransfer);
     $this->assertSame(self::SKU, $changeTransfer->getItems()[0]->getGroupKey());
 }
 /**
  * @return void
  */
 public function testSetTaxRateWhenExemptTaxRateUsedAndCountryMatchingShouldUseCountryRate()
 {
     $abstractProcuctEntity = $this->createAbstractProductWithTaxSet(20, 'DE');
     $quoteTransfer = new QuoteTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setIdProductAbstract($abstractProcuctEntity->getIdProductAbstract());
     $quoteTransfer->addItem($itemTransfer);
     $taxFacadeTest = $this->createTaxFacade();
     $taxFacadeTest->calculateProductItemTaxRate($quoteTransfer);
     $this->assertEquals('20.00', $itemTransfer->getTaxRate());
 }
Beispiel #10
0
 /**
  * @return \Generated\Shared\Transfer\WishlistTransfer
  */
 public function getWishlist()
 {
     $wishlist = $this->wishlistQueryContainer->queryWishlist()->findOneByFkCustomer($this->customerTransfer->getIdCustomer());
     $wishlistTransfer = new WishlistTransfer();
     foreach ($wishlist->getSpyWishlistItems() as $wishlistItemEntity) {
         $wishlistItemTransfer = new ItemTransfer();
         $productEntity = $wishlistItemEntity->getSpyProduct();
         $wishlistItemTransfer->setGroupKey($wishlistItemEntity->getGroupKey())->setAddedAt($wishlistItemEntity->getAddedAt())->setIdProductAbstract($wishlistItemEntity->getFkProductAbstract())->setSku($productEntity->getSku())->setQuantity($wishlistItemEntity->getQuantity());
         $wishlistTransfer->addItem($wishlistItemTransfer);
     }
     return $wishlistTransfer;
 }
 /**
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 protected function createCartChangeTransfer(array $cartItems)
 {
     $changeTransfer = new CartChangeTransfer();
     foreach ($cartItems as $cartItem => $options) {
         $cartItem = new ItemTransfer();
         foreach ($options as $option) {
             $cartItem->addProductOption($option);
         }
         $changeTransfer->addItem($cartItem);
     }
     return $changeTransfer;
 }
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $orderItems
  *
  * @return array
  */
 protected function getItemTransfers(array $orderItems)
 {
     $itemTransfers = [];
     foreach ($orderItems as $orderItem) {
         $itemTransfer = new ItemTransfer();
         $itemTransfer->fromArray($orderItem->toArray(), true);
         $itemTransfer->setUnitGrossPrice($orderItem->getGrossPrice());
         $itemTransfer->setGroupKey($orderItem->getSku());
         $itemTransfers[] = $itemTransfer;
     }
     return $itemTransfers;
 }
Beispiel #13
0
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $orderItemTransfer
  * @param int $idSalesOrder
  * @param int $idSalesOrderItem
  *
  * @return void
  */
 protected function saveOrderItemOptionDiscounts(ItemTransfer $orderItemTransfer, $idSalesOrder, $idSalesOrderItem)
 {
     foreach ($orderItemTransfer->getProductOptions() as $productOptionTransfer) {
         foreach ($productOptionTransfer->getCalculatedDiscounts() as $productOptionDiscountTransfer) {
             $salesDiscountEntity = $this->createSalesDiscountEntity($productOptionDiscountTransfer);
             $salesDiscountEntity->setFkSalesOrder($idSalesOrder);
             $salesDiscountEntity->setFkSalesOrderItem($idSalesOrderItem);
             $salesDiscountEntity->setFkSalesOrderItemOption($productOptionTransfer->getIdSalesOrderItemOption());
             $this->saveDiscount($salesDiscountEntity, $productOptionDiscountTransfer);
         }
     }
 }
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $item
  *
  * @return string
  */
 protected function buildGroupKey(ItemTransfer $item)
 {
     $currentGroupKey = $item->getGroupKey();
     if (!$item->getProductOptions()) {
         return $currentGroupKey;
     }
     $sortedProductOptions = $this->sortOptions((array) $item->getProductOptions());
     $optionGroupKey = $this->combineOptionParts($sortedProductOptions);
     if (empty($optionGroupKey)) {
         return $currentGroupKey;
     }
     return !empty($currentGroupKey) ? $currentGroupKey . '-' . $optionGroupKey : $optionGroupKey;
 }
 /**
  * @expectedException \Spryker\Zed\PriceCartConnector\Business\Exception\PriceMissingException
  * @expectedExceptionMessage Cart item 123 can not be priced
  *
  * @return void
  */
 public function testIsNotPriceAbleWithInvalidPrice()
 {
     $priceFacadeStub = $this->createPriceFacadeStub();
     $priceFacadeStub->addPriceStub('123', 1000);
     $priceFacadeStub->addValidityStub('123', false);
     $itemCollection = new CartChangeTransfer();
     $item = new ItemTransfer();
     $item->setId(123);
     $item->setSku(123);
     $itemCollection->addItem($item);
     $priceCartToPriceBridge = new PriceCartToPriceBridge($priceFacadeStub);
     $priceManager = new PriceManager($priceCartToPriceBridge, 'grossPrice');
     $priceManager->addGrossPriceToItems($itemCollection);
 }
 /**
  * @return \Generated\Shared\Transfer\OrderTransfer
  */
 protected function getOrderTransferWithRefundedItem()
 {
     $orderTransfer = new OrderTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setRefundableAmount(0);
     $itemTransfer->setIdSalesOrderItem(1);
     $orderTransfer->addItem($itemTransfer);
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setRefundableAmount(100);
     $itemTransfer->setIdSalesOrderItem(2);
     $orderTransfer->addItem($itemTransfer);
     $expenseTransfer = new ExpenseTransfer();
     $expenseTransfer->setRefundableAmount(10);
     $orderTransfer->addExpense($expenseTransfer);
     return $orderTransfer;
 }
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $orderItem
  *
  * @return \Generated\Shared\Transfer\RefundItemTransfer
  */
 protected function createRefundItem(ItemTransfer $orderItem)
 {
     $refundItem = new RefundItemTransfer();
     $refundItem->setFkSalesOrderItem($orderItem->getIdSalesOrderItem());
     $refundItem->setQuantity($orderItem->getQuantity());
     $refundItem->setGrossPrice($orderItem->getUnitGrossPrice());
     $refundItem->setDiscountAmount($orderItem->getSumTotalDiscountAmount());
     $refundItem->setName($orderItem->getName());
     $refundItem->setGroupKey($orderItem->getGroupKey());
     $refundItem->setTaxRate($orderItem->getTaxRate());
     $refundItem->setTaxAmount($orderItem->getSumTaxAmount());
     return $refundItem;
 }
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 private function getCheckoutRequestTransfer()
 {
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku('1234567890')->setQuantity(1)->setUnitGrossPriceWithProductOptions(10000)->setName('Socken');
     $billingAddressTransfer = new AddressTransfer();
     $billingAddressTransfer->setIso2Code('DE')->setEmail('*****@*****.**')->setFirstName('John')->setLastName('Doe')->setAddress1('Straße des 17. Juni')->setAddress2('135')->setZipCode('10623')->setCity('Berlin');
     $shippingAddressTransfer = new AddressTransfer();
     $shippingAddressTransfer->setIso2Code('DE')->setEmail('*****@*****.**')->setFirstName('John')->setLastName('Doe')->setAddress1('Fraunhoferstraße')->setAddress2('120')->setZipCode('80469')->setCity('München');
     $paymentAddressTransfer = (new AddressTransfer())->setFirstName('John')->setLastName('Doe')->setSalutation('Mr')->setEmail('*****@*****.**')->setCity('Berlin')->setIso2Code('DE')->setAddress1('Straße des 17. Juni')->setAddress2('135')->setZipCode('10623');
     $payolutionPaymentTransfer = (new PayolutionPaymentTransfer())->setGender('Male')->setDateOfBirth('1970-01-01')->setClientIp('127.0.0.1')->setAccountBrand(PayolutionConstants::BRAND_INVOICE)->setAddress($paymentAddressTransfer);
     $quoteTransfer = new QuoteTransfer();
     $totalsTransfer = new TotalsTransfer();
     $totalsTransfer->setGrandTotal(10000)->setSubtotal(10000);
     $quoteTransfer->setTotals($totalsTransfer);
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPaymentSelection('no_payment');
     $paymentTransfer->setPayolution($payolutionPaymentTransfer);
     $quoteTransfer->setPayment($paymentTransfer);
     $quoteTransfer->setShippingAddress($shippingAddressTransfer)->setBillingAddress($billingAddressTransfer);
     return $quoteTransfer;
 }
Beispiel #19
0
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer
  *
  * @throws \Spryker\Zed\Cart\Business\Exception\InvalidQuantityExeption
  *
  * @return bool
  */
 protected function isValidQuantity(ItemTransfer $itemTransfer)
 {
     if ($itemTransfer->getQuantity() < 1) {
         throw new InvalidQuantityExeption(sprintf('Could not change cart item "%d" with "%d" as value.', $itemTransfer->getSku(), $itemTransfer->getQuantity()));
     }
     return true;
 }
 /**
  * @return void
  */
 public function testSaveOrderCreatesAndFillsOrderItems()
 {
     $quoteTransfer = $this->getValidBaseQuoteTransfer();
     $initialState = SpyOmsOrderItemStateQuery::create()->filterByName(OmsConstants::INITIAL_STATUS)->findOneOrCreate();
     $initialState->save();
     $this->assertNotNull($initialState->getIdOmsOrderItemState());
     $item1 = new ItemTransfer();
     $item1->setName('item-test-1')->setSku('sku1')->setUnitGrossPrice(120)->setQuantity(2)->setTaxRate(19);
     $item2 = new ItemTransfer();
     $item2->setName('item-test-2')->setSku('sku2')->setUnitGrossPrice(130)->setQuantity(3)->setTaxRate(19);
     $quoteTransfer->addItem($item1);
     $quoteTransfer->addItem($item2);
     $item1Query = SpySalesOrderItemQuery::create()->filterByName('item-test-1');
     $item2Query = SpySalesOrderItemQuery::create()->filterByName('item-test-2');
     $checkoutResponseTransfer = $this->getValidBaseResponseTransfer();
     $this->salesFacade->saveOrder($quoteTransfer, $checkoutResponseTransfer);
     $savedItems = $checkoutResponseTransfer->getSaveOrder()->getOrderItems();
     $item1Entity = $item1Query->findOne();
     $item2Entity = $item2Query->findOne();
     $this->assertNotNull($item1Entity);
     $this->assertNotNull($item2Entity);
     $this->assertSame($savedItems[1]->getIdSalesOrderItem(), $item1Entity->getIdSalesOrderItem());
     $this->assertSame($item1->getName(), $item1Entity->getName());
     $this->assertSame($checkoutResponseTransfer->getSaveOrder()->getIdSalesOrder(), $item1Entity->getFkSalesOrder());
     $this->assertSame($initialState->getIdOmsOrderItemState(), $item1Entity->getFkOmsOrderItemState());
     $this->assertSame($item1->getSku(), $item1Entity->getSku());
     $this->assertSame($savedItems[1]->getUnitGrossPrice(), $item1Entity->getGrossPrice());
     $this->assertSame(1, $item1Entity->getQuantity());
     $this->assertSame($savedItems[3]->getIdSalesOrderItem(), $item2Entity->getIdSalesOrderItem());
     $this->assertSame($item2->getName(), $item2Entity->getName());
     $this->assertSame($checkoutResponseTransfer->getSaveOrder()->getIdSalesOrder(), $item2Entity->getFkSalesOrder());
     $this->assertSame($initialState->getIdOmsOrderItemState(), $item2Entity->getFkOmsOrderItemState());
     $this->assertSame($item2->getSku(), $item2Entity->getSku());
     $this->assertSame($savedItems[3]->getUnitGrossPrice(), $item2Entity->getGrossPrice());
     $this->assertSame(1, $item2Entity->getQuantity());
 }
Beispiel #21
0
 /**
  * @return void
  */
 public function testDecreaseCartItem()
 {
     $this->markTestSkipped('Tried to retrieve a concrete product with sku CONCRETE1, but it does not exist');
     $quoteTransfer = new QuoteTransfer();
     $cartItem = new ItemTransfer();
     $cartItem->setSku(self::DUMMY_1_SKU_CONCRETE_PRODUCT);
     $cartItem->setQuantity(3);
     $cartItem->setUnitGrossPrice(1);
     $quoteTransfer->addItem($cartItem);
     $newItem = new ItemTransfer();
     $newItem->setSku(self::DUMMY_1_SKU_CONCRETE_PRODUCT);
     $newItem->setQuantity(1);
     $newItem->setUnitGrossPrice(1);
     $cartChange = new CartChangeTransfer();
     $cartChange->setQuote($quoteTransfer);
     $cartChange->addItem($newItem);
     $changedCart = $this->cartFacade->decreaseQuantity($cartChange);
     $cartItems = $changedCart->getItems();
     $this->assertCount(1, $cartItems);
     /** @var \Generated\Shared\Transfer\ItemTransfer $changedItem */
     $changedItem = $cartItems[0];
     $this->assertEquals(2, $changedItem->getQuantity());
 }
Beispiel #22
0
 /**
  * @return void
  */
 public function testChangeItemQuantityMustCallAddItemQuantityWhenPassedItemQuantityIsLowerThenInCartGivenItem()
 {
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setQuantity(1);
     $itemTransfer->setSku('sku');
     $quoteTransfer = new QuoteTransfer();
     $quoteTransfer->addItem($itemTransfer);
     $sessionMock = $this->getSessionMock();
     $sessionMock->expects($this->exactly(3))->method('getQuote')->will($this->returnValue($quoteTransfer));
     $stubMock = $this->getStubMock();
     $stubMock->expects($this->never())->method('removeItem')->will($this->returnValue($quoteTransfer));
     $stubMock->expects($this->once())->method('addItem')->will($this->returnValue($quoteTransfer));
     $factoryMock = $this->getFactoryMock($sessionMock, $stubMock);
     $cartClientMock = $this->getCartClientMock($factoryMock);
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku('sku');
     $quoteTransfer = $cartClientMock->changeItemQuantity('sku', null, 2);
     $this->assertInstanceOf('Generated\\Shared\\Transfer\\QuoteTransfer', $quoteTransfer);
 }
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer
  *
  * @return void
  */
 protected function assertItemRequirements(ItemTransfer $itemTransfer)
 {
     $itemTransfer->requireUnitGrossPrice()->requireQuantity();
 }
Beispiel #24
0
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 protected function getBaseQuoteTransfer()
 {
     $quoteTransfer = new QuoteTransfer();
     $country = new SpyCountry();
     $country->setIso2Code('xi')->save();
     $productAbstract1 = new SpyProductAbstract();
     $productAbstract1->setSku('AOSB1337')->setAttributes('{}');
     $productConcrete1 = new SpyProduct();
     $productConcrete1->setSku('OSB1337')->setAttributes('{}')->setSpyProductAbstract($productAbstract1)->save();
     $productAbstract2 = new SpyProductAbstract();
     $productAbstract2->setSku('AOSB1338')->setAttributes('{}');
     $productConcrete2 = new SpyProduct();
     $productConcrete2->setSku('OSB1338')->setSpyProductAbstract($productAbstract2)->setAttributes('{}')->save();
     $stock = new SpyStock();
     $stock->setName('testStock');
     $stock1 = new SpyStockProduct();
     $stock1->setQuantity(1)->setStock($stock)->setSpyProduct($productConcrete1)->save();
     $stock2 = new SpyStockProduct();
     $stock2->setQuantity(1)->setStock($stock)->setSpyProduct($productConcrete2)->save();
     $item1 = new ItemTransfer();
     $item1->setSku('OSB1337')->setQuantity(1)->setUnitGrossPrice(3000)->setName('Product1');
     $item2 = new ItemTransfer();
     $item2->setSku('OSB1338')->setQuantity(1)->setUnitGrossPrice(4000)->setName('Product2');
     $quoteTransfer->addItem($item1);
     $quoteTransfer->addItem($item2);
     $totals = new TotalsTransfer();
     $totals->setGrandTotal(1000)->setSubtotal(500);
     $quoteTransfer->setTotals($totals);
     $billingAddress = new AddressTransfer();
     $shippingAddress = new AddressTransfer();
     $billingAddress->setIso2Code('xi')->setEmail('*****@*****.**')->setFirstName('Max')->setLastName('Mustermann')->setAddress1('Straße')->setAddress2('82')->setZipCode('12345')->setCity('Entenhausen');
     $shippingAddress->setIso2Code('xi')->setFirstName('Max')->setLastName('Mustermann')->setEmail('*****@*****.**')->setAddress1('Straße')->setAddress2('84')->setZipCode('12346')->setCity('Entenhausen2');
     $quoteTransfer->setBillingAddress($billingAddress);
     $quoteTransfer->setShippingAddress($shippingAddress);
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setIsGuest(false)->setEmail('*****@*****.**');
     $quoteTransfer->setCustomer($customerTransfer);
     $shipment = new ShipmentTransfer();
     $shipment->setMethod(new ShipmentMethodTransfer());
     $quoteTransfer->setShipment($shipment);
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPaymentSelection('no_payment');
     $quoteTransfer->setPayment($paymentTransfer);
     return $quoteTransfer;
 }
Beispiel #25
0
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer
  *
  * @return \Orm\Zed\Sales\Persistence\SpySalesOrderItem
  */
 protected function getSalesOrderItemEntity(ItemTransfer $itemTransfer)
 {
     $salesOrderItemEntity = $this->salesQueryContainer->querySalesOrderItem()->findOneByIdSalesOrderItem($itemTransfer->getIdSalesOrderItem());
     return $salesOrderItemEntity;
 }
Beispiel #26
0
 /**
  * @param int $index
  * @param \Generated\Shared\Transfer\ItemTransfer $itemToChange
  *
  * @return void
  */
 protected function decreaseItem($index, ItemTransfer $itemToChange)
 {
     $existingItems = $this->wishlistTransfer->getItems();
     $existingItem = $existingItems[$index];
     $newQuantity = $existingItem->getQuantity() - $itemToChange->getQuantity();
     if ($newQuantity > 0 && $itemToChange->getQuantity() > 0) {
         $existingItem->setQuantity($newQuantity);
     } else {
         unset($existingItems[$index]);
     }
 }
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer
  *
  * @return void
  */
 protected function setProductOptionAmountDefaults(ItemTransfer $itemTransfer)
 {
     $itemTransfer->setUnitGrossPriceWithProductOptions($itemTransfer->getUnitGrossPrice());
     $itemTransfer->setSumGrossPriceWithProductOptions($itemTransfer->getSumGrossPrice());
 }
Beispiel #28
0
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 protected function createQuoteTransfer()
 {
     $quoteTransfer = new QuoteTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setUnitGrossPrice(100);
     $quoteTransfer->addItem($itemTransfer);
     return $quoteTransfer;
 }
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer
  *
  * @return int
  */
 protected function getItemTotalDiscountAmount(ItemTransfer $itemTransfer)
 {
     return $this->getCalculatedDiscountsSumGrossAmount($itemTransfer->getCalculatedDiscounts());
 }
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  * @param \Generated\Shared\Transfer\ItemTransfer $currentItemTransfer
  * @param \Generated\Shared\Transfer\ClauseTransfer $clauseTransfer
  *
  * @return bool
  */
 public function isSatisfiedBy(QuoteTransfer $quoteTransfer, ItemTransfer $currentItemTransfer, ClauseTransfer $clauseTransfer)
 {
     $this->moneyValueConverter->convertDecimalToCent($clauseTransfer);
     return $this->comparators->compare($clauseTransfer, $currentItemTransfer->getUnitGrossPrice());
 }