/** * Event subscribed on OrderCoupon applied into an order. * * Just should create a new OrderCoupon instance, persist and flush it * * Also notifies to CouponBundle that a simple coupon has been * used by an Order. * * @param OrderCouponOnApplyEvent $event Event */ public function convertToOrderCoupons(OrderCouponOnApplyEvent $event) { $order = $event->getOrder(); $coupon = $event->getCoupon(); $orderCoupon = $this->orderCouponFactory->create()->setOrder($order)->setCoupon($coupon)->setAmount($coupon->getAbsolutePrice())->setName($coupon->getName())->setCode($coupon->getCode()); $this->orderCouponObjectManager->persist($orderCoupon); $this->orderCouponObjectManager->flush($orderCoupon); $event->setOrderCoupon($orderCoupon); $this->couponEventDispatcher->notifyCouponUsage($coupon); }
/** * Event subscribed on OrderCoupon applied into an order. * * Just should create a new OrderCoupon instance, persist and flush it * * Also notifies to CouponBundle that a simple coupon has been * used by an Order. * * @param OrderCouponOnApplyEvent $event Event */ public function createOrderCouponByCoupon(OrderCouponOnApplyEvent $event) { $orderCoupon = $this->couponToOrderCouponTransformer->createOrderCouponByCoupon($event->getOrder(), $event->getCoupon()); $event->setOrderCoupon($orderCoupon); }