Fix to order when auth user ordered for existing account
This commit is contained in:
@@ -58,20 +58,23 @@ class OrderController extends Controller
|
||||
// Check we have the custom attributes for the product
|
||||
$options = $po->orderValidation($request);
|
||||
|
||||
$uo = User::firstOrNew(['email'=>$request->input('order_email') ?: $request->input('order_email_manual')]);
|
||||
|
||||
// If this is a new client
|
||||
if (! $uo->exists)
|
||||
if ($request->input('order_email_manual'))
|
||||
{
|
||||
// @todo Make this automatic
|
||||
$uo->site_id = config('SITE_SETUP')->id;
|
||||
$uo->active = FALSE;
|
||||
$uo->firstname = '';
|
||||
$uo->lastname = '';
|
||||
$uo->country_id = config('SITE_SETUP')->country_id; // @todo This might be wrong
|
||||
$uo->parent_id = Auth::id() ?: 1; // @todo This should be configured to a default user
|
||||
$uo->active = 1;
|
||||
$uo->save();
|
||||
$uo = User::firstOrNew(['email'=>$request->input('order_email_manual')]);
|
||||
|
||||
// If this is a new client
|
||||
if (! $uo->exists)
|
||||
{
|
||||
// @todo Make this automatic
|
||||
$uo->site_id = config('SITE_SETUP')->id;
|
||||
$uo->active = FALSE;
|
||||
$uo->firstname = '';
|
||||
$uo->lastname = '';
|
||||
$uo->country_id = config('SITE_SETUP')->country_id; // @todo This might be wrong
|
||||
$uo->parent_id = Auth::id() ?: 1; // @todo This should be configured to a default user
|
||||
$uo->active = 1;
|
||||
$uo->save();
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a new account.
|
||||
@@ -88,10 +91,7 @@ class OrderController extends Controller
|
||||
$uo->accounts()->save($ao);
|
||||
|
||||
} else {
|
||||
// @todo This logic may be wrong, if account_id is not set, it'll pick the first account, which may be wrong.
|
||||
$ao = $request->input('account_id')
|
||||
? $uo->accounts->where('account_id',$request->input('account_id'))
|
||||
: $uo->accounts->first();
|
||||
$ao = Account::findOrFail($request->input('account_id'));
|
||||
}
|
||||
|
||||
$so = new Service;
|
||||
|
Reference in New Issue
Block a user