Skip to content

Commit

Permalink
Fix redirect issue in checkout component
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Oct 27, 2024
1 parent 379c9dc commit 86d733d
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/Livewire/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ public function render()

public function mount()
{
if ($redirect = $this->isOrderMarkedAsProcessed()) {
return $redirect;
if ($order = $this->isOrderMarkedAsProcessed()) {
return $this->redirect($order->getUrl($this->successPage));
}

if ($this->checkCheckoutSecurity()) {
Expand Down Expand Up @@ -201,8 +201,8 @@ public function onValidate()
return $this->redirect(restaurant_url($this->menusPage));
}

if ($redirect = $this->isOrderMarkedAsProcessed()) {
return $redirect;
if ($order = $this->isOrderMarkedAsProcessed()) {
return $this->redirect($order->getUrl($this->successPage));
}

$order = $this->getOrder();
Expand All @@ -223,8 +223,8 @@ public function onConfirm()
return $this->redirect(restaurant_url($this->menusPage));
}

if ($redirect = $this->isOrderMarkedAsProcessed()) {
return $redirect;
if ($order = $this->isOrderMarkedAsProcessed()) {
return $this->redirect($order->getUrl($this->successPage));
}

$order = $this->getOrder();
Expand All @@ -251,8 +251,8 @@ public function onConfirm()
return $redirect;
}

if ($redirect = $this->isOrderMarkedAsProcessed()) {
return $redirect;
if ($this->isOrderMarkedAsProcessed()) {
return $this->redirect($order->getUrl($this->successPage));
}
} catch (\Exception $ex) {
throw ValidationException::withMessages(['fields.payment' => $ex->getMessage()]);
Expand Down Expand Up @@ -378,11 +378,7 @@ protected function validateCheckout(Order $order)
protected function isOrderMarkedAsProcessed()
{
$order = $this->getOrder();
if (!$order->isPaymentProcessed()) {
return false;
}

return $this->redirect($order->getUrl($this->successPage));
return $order->isPaymentProcessed() ? $order : false;
}

protected function prepareDeliveryAddress()
Expand Down Expand Up @@ -431,8 +427,8 @@ protected function initForm(): void
File::symbolizePath('igniter-orange::/models/checkoutfields.php')
);

$config['model'] = $this->getOrder();
$this->checkoutForm = resolve(CheckoutForm::class, ['config' => $config]);
$this->checkoutForm->model = $this->getOrder();

$this->checkoutForm->bindEvent('form.extendFieldsBefore', function() {
$this->formExtendFieldsBefore($this->checkoutForm);
Expand Down

0 comments on commit 86d733d

Please sign in to comment.