Skip to content

Commit

Permalink
Fix Orders view page link to transform guest to customer
Browse files Browse the repository at this point in the history
  • Loading branch information
matks committed Jul 16, 2019
1 parent 8607b01 commit 52808a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -593,7 +593,8 @@
{if ($customer->isGuest())}
{l s='This order has been placed by a guest.' d='Admin.Orderscustomers.Feature'}
{if (!Customer::customerExists($customer->email))}
<form method="post" action="index.php?tab=AdminCustomers&amp;id_customer={$customer->id}&amp;id_order={$order->id|intval}&amp;token={getAdminToken tab='AdminCustomers'}">
<form method="post"
action="{$link->getAdminLink('AdminCustomers', true, [], ['guesttocustomer' => 1, 'id_customer' => $customer->id, 'id_order' => $order->id])}">
<input type="hidden" name="id_lang" value="{$order->id_lang}" />
<input class="btn btn-default" type="submit" name="submitGuestToCustomer" value="{l s='Transform a guest into a customer'}" />
<p class="help-block">{l s='This feature will generate a random password and send an email to the customer.' d='Admin.Orderscustomers.Help'}</p>
Expand Down
Expand Up @@ -311,10 +311,11 @@ public function setPrivateNoteAction($customerId, Request $request)
* )
*
* @param int $customerId
* @param Request $request
*
* @return RedirectResponse
*/
public function transformGuestToCustomerAction($customerId)
public function transformGuestToCustomerAction($customerId, Request $request)
{
try {
$this->getCommandBus()->handle(new TransformGuestToCustomerCommand((int) $customerId));
Expand All @@ -324,6 +325,15 @@ public function transformGuestToCustomerAction($customerId)
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
}

if ($request->query->get('id_order')) {
$legacyLink = $this->getAdminLink('AdminOrders', [
'id_order' => $request->query->get('id_order'),
'vieworder' => true,
]);

return $this->redirect($legacyLink);
}

return $this->redirectToRoute('admin_customers_view', [
'customerId' => $customerId,
]);
Expand Down

0 comments on commit 52808a6

Please sign in to comment.