corretto problema sul customer, che se era a zero non andava avanti.
This commit is contained in:
@@ -2222,10 +2222,30 @@ Route::post('/updatecreate', function (Request $request) {
|
||||
}
|
||||
|
||||
$productLogger->addLog('', 'Cerco il customer_id: ' . $request->customer_id);
|
||||
$customer = Customer::find($request->customer_id);
|
||||
|
||||
$CodClienteInternet = $request->customer_id;
|
||||
|
||||
if ($CodClienteInternet > 0) {
|
||||
$customer = Customer::find($CodClienteInternet);
|
||||
} else {
|
||||
$customer = $request;
|
||||
$customer['id'] = 0;
|
||||
$customer['last_name'] = $request->billing['last_name'];
|
||||
$customer['first_name'] = $request->billing['first_name'];
|
||||
$customer['billing'] = $request->billing;
|
||||
}
|
||||
$productLogger->addLog('', 'crea Cliente: ' . $customer['last_name'] . " " . $customer['first_name']);
|
||||
|
||||
$cliente = new Clientegm();
|
||||
|
||||
if ($CodClienteInternet > 0) {
|
||||
$clients = Clientegm::where('CodClienteInternet', $CodClienteInternet)->get();
|
||||
// se l'array non è vuoto
|
||||
if (!$clients->isEmpty()) {
|
||||
$cliente = $clients->first();
|
||||
}
|
||||
}
|
||||
|
||||
$cliente->CodClienteInternet = isset($customer['id']) ? $customer['id'] : '';
|
||||
$cliente->Nominativo = isset($customer['last_name']) ? $customer['last_name'] . " " . $customer['first_name'] : '';
|
||||
$cliente->Indirizzo = isset($customer['billing']->address_1) ? $customer['billing']->address_1 . " " . $customer['billing']->address_2 : '';
|
||||
@@ -2255,7 +2275,6 @@ Route::post('/updatecreate', function (Request $request) {
|
||||
if ($changedest) {
|
||||
$productLogger->addLog('', 'Change Destinazione:');
|
||||
$clientedest = new Clientegmdest();
|
||||
$clientedest = new Clientegmdest();
|
||||
$clientedest->CodDestInternet = $request->customer_id;
|
||||
$clientedest->Nominativo = $request->shipping['last_name'] ?? '';
|
||||
$clientedest->Indirizzo = $request->shipping['address_1'] ?? '';
|
||||
|
||||
Reference in New Issue
Block a user