コード例 #1
0
ファイル: SkuGroupKeyPlugin.php プロジェクト: spryker/Cart
 /**
  * @param \Generated\Shared\Transfer\CartChangeTransfer $cartChangeTransfer
  *
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 public function expandItems(CartChangeTransfer $cartChangeTransfer)
 {
     foreach ($cartChangeTransfer->getItems() as $cartItem) {
         $cartItem->setGroupKey($this->buildGroupKey($cartItem));
     }
     return $cartChangeTransfer;
 }
コード例 #2
0
 /**
  * @param \Generated\Shared\Transfer\CartChangeTransfer $change
  *
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 public function expand(CartChangeTransfer $change)
 {
     foreach ($change->getItems() as $item) {
         $item->setGroupKey($this->buildGroupKey($item));
     }
     return $change;
 }
コード例 #3
0
 /**
  * @param \Generated\Shared\Transfer\CartChangeTransfer $change
  *
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 public function expandProductOptions(CartChangeTransfer $change)
 {
     foreach ($change->getItems() as $cartItem) {
         $this->expandProductOptionTransfers($cartItem);
     }
     return $change;
 }
コード例 #4
0
 /**
  * @param \Generated\Shared\Transfer\CartChangeTransfer $change
  *
  * @throws \Spryker\Zed\PriceCartConnector\Business\Exception\PriceMissingException
  *
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 public function addGrossPriceToItems(CartChangeTransfer $change)
 {
     foreach ($change->getItems() as $cartItem) {
         if (!$this->priceFacade->hasValidPrice($cartItem->getSku(), $this->grossPriceType)) {
             throw new PriceMissingException(sprintf('Cart item %s can not be priced', $cartItem->getSku()));
         }
         $cartItem->setUnitGrossPrice($this->priceFacade->getPriceBySku($cartItem->getSku(), $this->grossPriceType));
     }
     return $change;
 }
コード例 #5
0
 /**
  * @param \Generated\Shared\Transfer\CartChangeTransfer $change
  *
  * @return \Generated\Shared\Transfer\CartChangeTransfer
  */
 public function expandItems(CartChangeTransfer $change)
 {
     foreach ($change->getItems() as $cartItem) {
         $productConcreteTransfer = $this->productFacade->getProductConcrete($cartItem->getSku());
         $cartItem->setId($productConcreteTransfer->getIdProductConcrete())->setSku($productConcreteTransfer->getSku())->setIdProductAbstract($productConcreteTransfer->getIdProductAbstract())->setAbstractSku($productConcreteTransfer->getProductAbstractSku())->setName($productConcreteTransfer->getName());
         if ($productConcreteTransfer->getTaxRate() !== null) {
             $cartItem->setTaxRate($productConcreteTransfer->getTaxRate());
         }
     }
     return $change;
 }
コード例 #6
0
 /**
  * @param \Generated\Shared\Transfer\CartChangeTransfer $cartChangeTransfer
  *
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 public function removeItems(CartChangeTransfer $cartChangeTransfer)
 {
     $existingItems = $cartChangeTransfer->getQuote()->getItems();
     $cartIndex = $this->createCartIndex($existingItems);
     foreach ($cartChangeTransfer->getItems() as $itemTransfer) {
         $this->isValidQuantity($itemTransfer);
         $itemIdentifier = $this->getItemIdentifier($itemTransfer);
         if (isset($cartIndex[$itemIdentifier])) {
             $this->decreaseExistingItem($existingItems, $cartIndex[$itemIdentifier], $itemTransfer);
         }
     }
     return $cartChangeTransfer->getQuote();
 }