fix errori se non esistono dei campi...
This commit is contained in:
@@ -631,7 +631,7 @@ Route::get('/artlibronuovo', function () {
|
||||
'key' => 'DataPubblicazione',
|
||||
'value' => $article->DataPubblicazione
|
||||
],
|
||||
[
|
||||
[
|
||||
'key' => 'misure',
|
||||
'value' => $article->Misure
|
||||
],
|
||||
@@ -1987,7 +1987,7 @@ Route::get('/artlibro1', function () {
|
||||
->where('DescrizioneTipologia', 'Dvd')
|
||||
->orderBy('Titolo')
|
||||
->orderBy('DescrizioneTipologia')
|
||||
|
||||
|
||||
//->take(5)
|
||||
//->orderBy('ListaAutori')
|
||||
->get();
|
||||
@@ -2187,7 +2187,7 @@ Route::post('/updatecreate', function (Request $request) {
|
||||
}
|
||||
$order->save();
|
||||
$productLogger->addLog('', 'Order:' . json_encode($order));
|
||||
|
||||
|
||||
|
||||
$prodotti = $request->line_items;
|
||||
foreach ($prodotti as $prodotto) {
|
||||
@@ -2200,7 +2200,6 @@ Route::post('/updatecreate', function (Request $request) {
|
||||
}
|
||||
if ($codifica) {
|
||||
$productLogger->addLog('', 'ORDINE LIBRO USATO !');
|
||||
|
||||
} else {
|
||||
$orderdetail->CodArticoloGM = intval($prodotto['sku']);
|
||||
$productLogger->addLog('', '$orderdetail->CodArticoloGM= ' . $orderdetail->CodArticoloGM);
|
||||
@@ -2213,23 +2212,25 @@ Route::post('/updatecreate', function (Request $request) {
|
||||
$orderdetail->Enabled = 1;
|
||||
$orderdetail->DataOra = $request->date_created;
|
||||
$orderdetail->save();
|
||||
|
||||
|
||||
$productLogger->addLog('', 'Dettaglio Ordine: ' . json_encode($orderdetail));
|
||||
}
|
||||
|
||||
$productLogger->addLog('', 'Cerco il customer_id: ' . $request->customer_id);
|
||||
$customer = Customer::find($request->customer_id);
|
||||
$productLogger->addLog('', 'crea Cliente: ' . $customer['last_name'] . " " . $customer['first_name']);
|
||||
|
||||
$cliente = new Clientegm();
|
||||
$cliente->CodClienteInternet = $customer['id'];
|
||||
$cliente->Nominativo = $customer['last_name'] . " " . $customer['first_name'];
|
||||
$cliente->Indirizzo = $customer['billing']->address_1 . " " . $customer['billing']->address_2;
|
||||
$cliente->Citta = $customer['billing']->city;
|
||||
$cliente->Cap = $customer['billing']->postcode;
|
||||
$cliente->Provincia = $customer['billing']->state;
|
||||
$cliente->Telefono = $customer['billing']->phone;
|
||||
$cliente->Email = $customer['billing']->email;
|
||||
$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 : '';
|
||||
$cliente->Citta = isset($customer['billing']->city) ? $customer['billing']->city : '';
|
||||
$cliente->Cap = isset($customer['billing']->postcode) ? $customer['billing']->postcode : '';
|
||||
$cliente->Provincia = isset($customer['billing']->state) ? $customer['billing']->state : '';
|
||||
$cliente->Telefono = isset($customer['billing']->phone) ? $customer['billing']->phone : '';
|
||||
$cliente->Email = isset($customer['billing']->email) ? $customer['billing']->email : '';
|
||||
$cliente->IdNazione = 227;
|
||||
|
||||
$metas = $customer['meta_data'];
|
||||
foreach ($metas as $meta) {
|
||||
|
||||
@@ -2240,6 +2241,8 @@ Route::post('/updatecreate', function (Request $request) {
|
||||
}
|
||||
}
|
||||
$cliente->IdInternet = $request->id;
|
||||
|
||||
$productLogger->addLog('', ' ...fine compilazione campi Cliente');
|
||||
$cliente->save();
|
||||
|
||||
$productLogger->addLog('', 'Salvato Cliente:' . json_encode($cliente));
|
||||
@@ -2247,17 +2250,19 @@ 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'] . " " . $request->shipping['first_name'];
|
||||
$clientedest->Indirizzo = $request->shipping['address_1'] . " " . $request->shipping['address_2'];
|
||||
$clientedest->Citta = $request->shipping['city'];
|
||||
$clientedest->Cap = $request->shipping['postcode'];
|
||||
$clientedest->Provincia = $request->shipping['state'];
|
||||
$clientedest->Telefono = $request->shipping['phone'];
|
||||
$cliente->IdNazione = 227;
|
||||
$clientedest->Nominativo = $request->shipping['last_name'] ?? '';
|
||||
$clientedest->Indirizzo = $request->shipping['address_1'] ?? '';
|
||||
$clientedest->Indirizzo .= $request->shipping['address_2'] ?? '';
|
||||
$clientedest->Citta = $request->shipping['city'] ?? '';
|
||||
$clientedest->Cap = $request->shipping['postcode'] ?? '';
|
||||
$clientedest->Provincia = $request->shipping['state'] ?? '';
|
||||
$clientedest->Telefono = $request->shipping['phone'] ?? '';
|
||||
$clientedest->IdNazione = 227;
|
||||
$clientedest->IdInternet = $request->id;
|
||||
$clientedest->save();
|
||||
|
||||
|
||||
try {
|
||||
$productLogger->addLog('', 'Cliente Dest:' . json_encode($clientedest));
|
||||
} catch (Exception $e) {
|
||||
@@ -2267,11 +2272,10 @@ Route::post('/updatecreate', function (Request $request) {
|
||||
$productLogger->addLog('', 'Inserito ordine ! ');
|
||||
try {
|
||||
$productLogger->addLog('', json_encode($request->all()));
|
||||
} catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
$productLogger->setLogandSendEmail('Nuovo Ordine !');
|
||||
|
||||
$productLogger->setLogandSendEmail('Nuovo Ordine !');
|
||||
} //end if status
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user