From d98d8fdb2ab394bd2dcae233173a742f36d65607 Mon Sep 17 00:00:00 2001 From: Alexandre Severo Date: Tue, 15 Aug 2023 15:46:56 -0700 Subject: [PATCH] move referral logic to later in the process --- src/Services/OrderFormService.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Services/OrderFormService.php b/src/Services/OrderFormService.php index b2c11119..0dc6e175 100755 --- a/src/Services/OrderFormService.php +++ b/src/Services/OrderFormService.php @@ -215,15 +215,6 @@ public function processOrderFormSubmit(OrderFormSubmitRequest $request): array // create and login the user or create the customer $this->purchaserService->persist($purchaser); - // CMT-77 apply referral if it is so - if ($request->get('referralCode')) { - $item = array_key_first($cart->getItems()); - $this->applyReferral( - $request->get('brand'), - $request->get('referralCode'), - $purchaser, - $cart->getItems()[$item]->getSku()); // as it is only one product, get the sku for the first item in the card - } if ($purchaser->getType() == Purchaser::USER_TYPE) { DiscountCriteriaService::setPurchaser($purchaser->getUserObject()); @@ -433,6 +424,15 @@ public function processOrderFormSubmit(OrderFormSubmitRequest $request): array //remove all items from the cart $this->cartService->clearCart(); + // CMT-77 apply referral if it is so + if ($request->get('referralCode')) { + $item = array_key_first($cart->getItems()); + $this->applyReferral( + $request->get('brand'), + $request->get('referralCode'), + $purchaser, + $cart->getItems()[$item]->getSku()); // as it is only one product, get the sku for the first item in the card + } return ['order' => $order]; } }