/** * @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; }
/** * @param \Generated\Shared\Transfer\DiscountableItemTransfer $discountableItemTransfer * * @return int */ protected function getDiscountableObjectQuantity(DiscountableItemTransfer $discountableItemTransfer) { $quantity = $discountableItemTransfer->getQuantity(); if (empty($quantity)) { return 1; } return $quantity; }
/** * @param \Generated\Shared\Transfer\DiscountableItemTransfer $discountableItemTransfer * * @return int */ protected function getDiscountableItemQuantity(DiscountableItemTransfer $discountableItemTransfer) { $quantity = 1; if ($discountableItemTransfer->getQuantity()) { $quantity = $discountableItemTransfer->getQuantity(); } return $quantity; }
/** * @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; }
/** * @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; }
/** * @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; }