/**
  * @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;
 }
コード例 #2
0
 /**
  * @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());
     }
 }
コード例 #3
0
 /**
  * @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());
     }
 }
コード例 #4
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);
         }
     }
 }
コード例 #5
0
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $item
  *
  * @return float
  */
 protected function getEffectiveProductOptionTaxRate(ItemTransfer $item)
 {
     $taxSum = 0;
     foreach ($item->getProductOptions() as $productOption) {
         $taxSum += $productOption->getTaxRate();
     }
     return $taxSum;
 }
コード例 #6
0
 /**
  * @param \Generated\Shared\Transfer\ItemTransfer $item
  * @param array $taxRates
  *
  * @return void
  */
 protected function setProductOptionTaxRate(ItemTransfer $item, array $taxRates)
 {
     foreach ($item->getProductOptions() as $productOption) {
         $productOption->setTaxRate($this->getEffectiveTaxRate($taxRates, $productOption->getIdOptionValueUsage()));
     }
 }