Skip to content

Commit

Permalink
Merge pull request #29 from railroadmedia/august-referral-contest
Browse files Browse the repository at this point in the history
move referral logic to later in the process
  • Loading branch information
alesevero authored Aug 15, 2023
2 parents c612a1d + d98d8fd commit 33efcf2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Services/OrderFormService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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];
}
}

0 comments on commit 33efcf2

Please sign in to comment.