Example #1
0
 /**
  * Define query for 'findOneSimilarDiscount' method
  * 
  * @param \XLite\Module\CDev\VolumeDiscounts\Model\VolumeDiscount $model Discount
  *  
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 protected function definefindOneSimilarDiscountQuery(\XLite\Module\CDev\VolumeDiscounts\Model\VolumeDiscount $model)
 {
     $qb = $this->createQueryBuilder()->andWhere('v.subtotalRangeBegin = :rangeBegin')->setParameter('rangeBegin', $model->getSubtotalRangeBegin())->setMaxResults(1);
     if ($model->getMembership()) {
         $qb->andWhere('v.membership = :membership')->setParameter('membership', $model->getMembership());
     } else {
         $qb->andWhere('v.membership IS NULL');
     }
     return $qb;
 }
Example #2
0
 /**
  * Returns true if next discount rate is available for cart
  *
  * @return boolean
  */
 protected function hasNextDiscount()
 {
     if (null === $this->nextDiscount) {
         $this->nextDiscount = $this->getNextDiscount();
         if (null !== $this->nextDiscount) {
             $nextValue = $this->getCart()->getCurrency()->formatValue($this->nextDiscount->getAmount($this->getCart()));
             $currentValue = 0;
             if (0 < $nextValue) {
                 $currentDiscount = $this->getCurrentDiscount();
                 if ($currentDiscount) {
                     $currentValue = $this->getCart()->getCurrency()->formatValue($currentDiscount->getAmount($this->getCart()));
                 }
             }
             if ($nextValue <= $currentValue) {
                 $this->nextDiscount = null;
             }
         }
     }
     return null !== $this->nextDiscount;
 }
 /**
  * {@inheritDoc}
  */
 public function prepareEntityBeforeCommit($type)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type));
     return parent::prepareEntityBeforeCommit($type);
 }