Example #1
0
 /**
  * @param \Orm\Zed\Discount\Persistence\SpyDiscountVoucher $discountVoucherEntity
  *
  * @return bool
  */
 protected function isValidNumberOfUses(SpyDiscountVoucher $discountVoucherEntity)
 {
     if ($discountVoucherEntity->getMaxNumberOfUses() > 0 && $discountVoucherEntity->getNumberOfUses() >= $discountVoucherEntity->getMaxNumberOfUses()) {
         return false;
     }
     return true;
 }
 /**
  * @param \Orm\Zed\Discount\Persistence\SpyDiscountVoucher $discountVoucherEntity
  *
  * @return string
  */
 protected function buildLinks(SpyDiscountVoucher $discountVoucherEntity)
 {
     $buttons = [];
     $deleteVoucherCodeUrl = Url::generate('/discount/voucher/delete-voucher-code', ['id-discount' => $this->idDiscount, 'id-voucher' => $discountVoucherEntity->getIdDiscountVoucher()])->build();
     $buttons[] = $this->generateRemoveButton($deleteVoucherCodeUrl, 'Delete');
     return implode(' ', $buttons);
 }
Example #3
0
 /**
  * @param \Orm\Zed\Discount\Persistence\SpyDiscountVoucher $discountVoucherEntity
  *
  * @return int
  */
 protected function saveDiscountVoucherEntity(SpyDiscountVoucher $discountVoucherEntity)
 {
     return $discountVoucherEntity->save();
 }
 /**
  * @return \Orm\Zed\Discount\Persistence\SpyDiscountVoucher
  */
 public function getDiscountVoucherEntityByCode()
 {
     $discountVoucherEntity = new SpyDiscountVoucher();
     $discountVoucherPoolEntity = new SpyDiscountVoucherPool();
     $discountVoucherEntity->setVoucherPool($discountVoucherPoolEntity);
     return $discountVoucherEntity;
 }
Example #5
0
 /**
  * @param \Generated\Shared\Transfer\DiscountVoucherTransfer $discountVoucherTransfer
  * @param \Orm\Zed\Discount\Persistence\SpyDiscountVoucher $voucherEntity
  *
  * @return void
  */
 protected function hydrateDiscountVoucherEntity(DiscountVoucherTransfer $discountVoucherTransfer, SpyDiscountVoucher $voucherEntity)
 {
     $voucherEntity->fromArray($discountVoucherTransfer->toArray());
     $voucherEntity->setIsActive(true);
 }
 /**
  * @param string $voucherCode
  * @param \Orm\Zed\Discount\Persistence\SpyDiscount $discountEntity
  *
  * @return \Orm\Zed\Discount\Persistence\SpyDiscountVoucher
  */
 protected function createVoucherCode($voucherCode, SpyDiscount $discountEntity)
 {
     $voucherEntity = new SpyDiscountVoucher();
     $voucherEntity->setFkDiscountVoucherPool($discountEntity->getFkDiscountVoucherPool());
     $voucherEntity->setCode($voucherCode);
     $voucherEntity->setIsActive(true);
     $voucherEntity->save();
     return $voucherEntity;
 }