コード例 #1
0
ファイル: BaseCollector.php プロジェクト: spryker/Discount
 /**
  * @param int $grossPrice
  * @param int $quantity
  * @param \ArrayObject $originalItemCalculatedDiscounts
  *
  * @return \Generated\Shared\Transfer\DiscountableItemTransfer
  */
 protected function createDiscountableItemTransfer($grossPrice, $quantity, \ArrayObject $originalItemCalculatedDiscounts)
 {
     $discountableItemTransfer = new DiscountableItemTransfer();
     $discountableItemTransfer->setUnitGrossPrice($grossPrice);
     $discountableItemTransfer->setQuantity($quantity);
     $discountableItemTransfer->setOriginalItemCalculatedDiscounts($originalItemCalculatedDiscounts);
     return $discountableItemTransfer;
 }
コード例 #2
0
ファイル: Percentage.php プロジェクト: spryker/Discount
 /**
  * @param \Generated\Shared\Transfer\DiscountableItemTransfer $discountableItemTransfer
  *
  * @return int
  */
 protected function getDiscountableObjectQuantity(DiscountableItemTransfer $discountableItemTransfer)
 {
     $quantity = $discountableItemTransfer->getQuantity();
     if (empty($quantity)) {
         return 1;
     }
     return $quantity;
 }
コード例 #3
0
ファイル: Distributor.php プロジェクト: spryker/Discount
 /**
  * @param \Generated\Shared\Transfer\DiscountableItemTransfer $discountableItemTransfer
  *
  * @return int
  */
 protected function getDiscountableItemQuantity(DiscountableItemTransfer $discountableItemTransfer)
 {
     $quantity = 1;
     if ($discountableItemTransfer->getQuantity()) {
         $quantity = $discountableItemTransfer->getQuantity();
     }
     return $quantity;
 }
コード例 #4
0
ファイル: PercentageTest.php プロジェクト: spryker/Discount
 /**
  * @param array $grossPrices
  *
  * @return \Generated\Shared\Transfer\DiscountableItemTransfer[]
  */
 protected function getDiscountableItems(array $grossPrices)
 {
     $items = [];
     foreach ($grossPrices as $grossPrice) {
         $discountableItems = new DiscountableItemTransfer();
         $discountableItems->setUnitGrossPrice($grossPrice);
         $discountableItems->setQuantity(1);
         $discountableItems->setOriginalItemCalculatedDiscounts(new \ArrayObject());
         $items[] = $discountableItems;
     }
     return $items;
 }
コード例 #5
0
ファイル: CalculatorTest.php プロジェクト: spryker/Discount
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  *
  * @return array|\Generated\Shared\Transfer\DiscountableItemTransfer[]
  */
 protected function createDiscountableItemsFromQuoteTransfer(QuoteTransfer $quoteTransfer)
 {
     $discountableItems = [];
     foreach ($quoteTransfer->getItems() as $itemTransfer) {
         $discountableItemTransfer = new DiscountableItemTransfer();
         $discountableItemTransfer->fromArray($itemTransfer->toArray(), true);
         $discountableItemTransfer->setOriginalItemCalculatedDiscounts($itemTransfer->getCalculatedDiscounts());
         $discountableItems[] = $discountableItemTransfer;
     }
     return $discountableItems;
 }
コード例 #6
0
ファイル: DistributorTest.php プロジェクト: spryker/Discount
 /**
  * @param array $items
  *
  * @return \ArrayObject
  */
 protected function createDiscountableObjects($items = [])
 {
     $discountableObjects = new \ArrayObject();
     foreach ($items as $item) {
         $discountableItemTransfer = new DiscountableItemTransfer();
         $discountableItemTransfer->setUnitGrossPrice($item['unit_gross_price']);
         $discountableItemTransfer->setQuantity(1);
         $discountableItemTransfer->setOriginalItemCalculatedDiscounts(new \ArrayObject());
         $discountableObjects->append($discountableItemTransfer);
     }
     return $discountableObjects;
 }