/**
  * @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());
     }
 }
 /**
  * @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;
 }
Beispiel #3
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;
 }
Beispiel #4
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]);
     }
 }
Beispiel #5
0
 /**
  * @param \Orm\Zed\Wishlist\Persistence\SpyWishlistItem $wishlistItemEntity
  * @param \Generated\Shared\Transfer\ItemTransfer $wishlistItemTransfer
  *
  * @return void
  */
 protected function updateWishlistItem(SpyWishlistItem $wishlistItemEntity, ItemTransfer $wishlistItemTransfer)
 {
     $wishlistItemEntity->setQuantity($wishlistItemEntity->getQuantity() + $wishlistItemTransfer->getQuantity());
     $wishlistItemEntity->save();
 }
 /**
  * @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)
 {
     return $this->comparators->compare($clauseTransfer, $currentItemTransfer->getQuantity());
 }