Fixes for ordering

This commit is contained in:
Deon George
2021-07-09 11:39:27 +10:00
parent 24ff62094a
commit a9f81373fa
5 changed files with 255 additions and 251 deletions

View File

@@ -40,9 +40,7 @@ class OrderController extends Controller
public function submit(Request $request)
{
Validator::make($request->all(),[
'product_id'=>'required|exists:ab_product,id',
])
Validator::make($request->all(),['product_id'=>'required|exists:ab_product,id'])
// Reseller
->sometimes('account_id','required|email',function($input) use ($request) {
return is_null($input->account_id) AND is_null($input->order_email_manual);
@@ -63,15 +61,13 @@ class OrderController extends Controller
// Check we have the custom attributes for the product
$options = $po->orderValidation($request);
if ($request->input('order_email_manual'))
{
if ($request->input('order_email_manual')) {
$uo = User::firstOrNew(['email'=>$request->input('order_email_manual')]);
// If this is a new client
if (! $uo->exists)
{
if (! $uo->exists) {
// @todo Make this automatic
$uo->site_id = config('SITE')->id;
$uo->site_id = config('SITE')->site_id;
$uo->active = FALSE;
$uo->firstname = '';
$uo->lastname = '';
@@ -83,12 +79,11 @@ class OrderController extends Controller
}
// If we have a new account.
if (is_null($request->input('account_id')))
{
if (is_null($request->input('account_id'))) {
$ao = new Account;
//$ao->id = Account::NextId();
// @todo Make this automatic
$ao->site_id = config('SITE')->id;
$ao->site_id = config('SITE')->site_id;
$ao->country_id = config('SITE')->country_id; // @todo This might be wrong
$ao->language_id = config('SITE')->language_id; // @todo This might be wrong
$ao->currency_id = config('SITE')->currency_id; // @todo This might be wrong
@@ -102,15 +97,15 @@ class OrderController extends Controller
$so = new Service;
// @todo Make this automatic
$so->site_id = config('SITE')->id;
$so->site_id = config('SITE')->site_id;
$so->product_id = $request->input('product_id');
$so->order_status = 'ORDER-SUBMIT';
$so->orderby_id = Auth::id();
$so->model = get_class($options);
if ($options->order_info)
{
if ($options->order_info) {
$so->order_info = $options->order_info;
unset($options->order_info);
}