Esempio n. 1
0
 /**
  * @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)
 {
     $currentTime = $this->convertToSeconds($this->getCurrentTime());
     $compareWithTime = $this->convertToSeconds($clauseTransfer->getValue());
     $clauseTransfer->setValue($compareWithTime);
     return $this->comparators->compare($clauseTransfer, $currentTime);
 }
Esempio n. 2
0
 /**
  * @param \Generated\Shared\Transfer\ClauseTransfer $clauseTransfer
  *
  * @throws \Spryker\Zed\Discount\Business\Exception\QueryStringException
  *
  * @return void
  */
 protected function validateComparatorOperators(ClauseTransfer $clauseTransfer)
 {
     if ($this->comparatorOperators->isExistingComparator($clauseTransfer) === false) {
         throw new QueryStringException(sprintf('Could not find value "%s" as comparator operator.', $clauseTransfer->getOperator()));
     }
     $this->comparatorOperators->isValidComparatorValue($clauseTransfer);
 }
Esempio n. 3
0
 /**
  * @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)
 {
     if (!$quoteTransfer->getTotals()) {
         return false;
     }
     $this->moneyValueConverter->convertDecimalToCent($clauseTransfer);
     return $this->comparators->compare($clauseTransfer, $quoteTransfer->getTotals()->getSubtotal());
 }
Esempio n. 4
0
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  * @param \Generated\Shared\Transfer\ClauseTransfer $clauseTransfer
  *
  * @return \Generated\Shared\Transfer\DiscountableItemTransfer[]
  */
 public function collect(QuoteTransfer $quoteTransfer, ClauseTransfer $clauseTransfer)
 {
     $discountableItems = [];
     foreach ($quoteTransfer->getItems() as $itemTransfer) {
         if ($this->comparators->compare($clauseTransfer, $itemTransfer->getSku()) === false) {
             continue;
         }
         $discountableItems[] = $this->createDiscountableItemTransfer($itemTransfer->getUnitGrossPrice(), $itemTransfer->getQuantity(), $itemTransfer->getCalculatedDiscounts());
     }
     return $discountableItems;
 }
Esempio n. 5
0
 /**
  * @param string $token
  *
  * @return bool
  */
 protected function isComparator($token)
 {
     if (in_array($token, $this->getCompoundComparatorExpressions(), true)) {
         return true;
     }
     $clauseTransfer = new ClauseTransfer();
     $clauseTransfer->setOperator($token);
     return $this->comparatorOperators->isExistingComparator($clauseTransfer);
 }
 /**
  * @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)
 {
     $totalQuantity = $this->getQuoteItemQuantity($quoteTransfer);
     return $this->comparators->compare($clauseTransfer, $totalQuantity);
 }
Esempio n. 7
0
 /**
  * @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)
 {
     $this->moneyValueConverter->convertDecimalToCent($clauseTransfer);
     return $this->comparators->compare($clauseTransfer, $currentItemTransfer->getUnitGrossPrice());
 }
Esempio n. 8
0
 /**
  * @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)
 {
     $currentMonth = $this->getCurrentMonth();
     return $this->comparators->compare($clauseTransfer, $currentMonth);
 }
Esempio n. 9
0
 /**
  * @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->getSku());
 }
 /**
  * @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)
 {
     $calendarWeek = $this->getCalendarWeek();
     return $this->comparators->compare($clauseTransfer, $calendarWeek);
 }