logga il dettagli dell'ordine
This commit is contained in:
194
routes/web.php
194
routes/web.php
@@ -814,7 +814,7 @@ Route::get('/artlibrousato', function () {
|
|||||||
}
|
}
|
||||||
echo "Finito";
|
echo "Finito";
|
||||||
*/
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get(
|
Route::get(
|
||||||
'/test2',
|
'/test2',
|
||||||
@@ -1670,7 +1670,8 @@ Route::get('/autori_test', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function getvalstr($mystr, $value, $separato = false) {
|
function getvalstr($mystr, $value, $separato = false)
|
||||||
|
{
|
||||||
$my = '';
|
$my = '';
|
||||||
if ($mystr) {
|
if ($mystr) {
|
||||||
$my = " " . $mystr . ": " . $value;
|
$my = " " . $mystr . ": " . $value;
|
||||||
@@ -1686,7 +1687,6 @@ function getvalstr($mystr, $value, $separato = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $my;
|
return $my;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2140,108 +2140,115 @@ Route::post('/updatecreate', function (Request $request) {
|
|||||||
|
|
||||||
//dd($webhook);
|
//dd($webhook);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
if (($request->status == 'on-hold' && $request->payment_method == 'bacs') || ($request->status == 'processing' && $request->payment_method == 'wc_gateway_gestpay') || ($request->status == 'processing' && $request->payment_method == 'paypal')) {
|
Log::info('updatecreate: ARRIVATO ORDINE');
|
||||||
$changedest = false;
|
|
||||||
if (($request->shipping['address_1'] != null && $request->shipping['address_1'] != '' && $request->shipping['address_1'] != $request->billing['address_1']) || ($request->shipping['first_name'] != null && $request->shipping['first_name'] != '' && $request->shipping['first_name'] != $request->billing['first_name'])) {
|
|
||||||
$changedest = true;
|
|
||||||
}
|
|
||||||
//$orderold =
|
|
||||||
$order = new Order();
|
|
||||||
$order->IdInternet = $request->id;
|
|
||||||
$order->CodClienteInternet = $request->customer_id;
|
|
||||||
$order->Enabled = 1;
|
|
||||||
$order->DataOra = $request->date_created;
|
|
||||||
$order->Note = $request->customer_note;
|
|
||||||
$order->Totale = $request->total;
|
|
||||||
if ($request->payment_method == 'wc_gateway_gestpay') {
|
|
||||||
$order->CodPagamentoGM = 'CARTASELLA';
|
|
||||||
}
|
|
||||||
if ($request->payment_method == 'paypal') {
|
|
||||||
$order->CodPagamentoGM = '472';
|
|
||||||
}
|
|
||||||
if ($request->payment_method == 'bacs') {
|
|
||||||
$order->CodPagamentoGM = 'BONIFPOSTALE';
|
|
||||||
$order->FlagSospeso = 1;
|
|
||||||
}
|
|
||||||
$order->Spedizioniere = 'GLS';
|
|
||||||
$order->ImportoSpedizione = $request->shipping_total;
|
|
||||||
|
|
||||||
if ($changedest) {
|
if (($request->status == 'on-hold' && $request->payment_method == 'bacs') || ($request->status == 'processing' && $request->payment_method == 'wc_gateway_gestpay') || ($request->status == 'processing' && $request->payment_method == 'paypal')) {
|
||||||
$order->CodDestInternet = $request->customer_id;
|
$changedest = false;
|
||||||
}
|
if (($request->shipping['address_1'] != null && $request->shipping['address_1'] != '' && $request->shipping['address_1'] != $request->billing['address_1']) || ($request->shipping['first_name'] != null && $request->shipping['first_name'] != '' && $request->shipping['first_name'] != $request->billing['first_name'])) {
|
||||||
$order->save();
|
$changedest = true;
|
||||||
|
|
||||||
$prodotti = $request->line_items;
|
|
||||||
foreach ($prodotti as $prodotto) {
|
|
||||||
$orderdetail = new Orderdetail();
|
|
||||||
$orderdetail->IdInternet = $request->id;
|
|
||||||
$sku = $prodotto['sku'];
|
|
||||||
$codifica = false;
|
|
||||||
if (strlen($sku) > 7 || strpos($sku, 'USATO') === 0) {
|
|
||||||
$codifica = true;
|
|
||||||
}
|
}
|
||||||
if ($codifica) {
|
//$orderold =
|
||||||
|
Log::info('Creazione Ordine... codice=' . $request->id);
|
||||||
} else {
|
$order = new Order();
|
||||||
$orderdetail->CodArticoloGM = intval($prodotto['sku']);
|
$order->IdInternet = $request->id;
|
||||||
|
$order->CodClienteInternet = $request->customer_id;
|
||||||
|
$order->Enabled = 1;
|
||||||
|
$order->DataOra = $request->date_created;
|
||||||
|
$order->Note = $request->customer_note;
|
||||||
|
$order->Totale = $request->total;
|
||||||
|
if ($request->payment_method == 'wc_gateway_gestpay') {
|
||||||
|
$order->CodPagamentoGM = 'CARTASELLA';
|
||||||
}
|
}
|
||||||
|
if ($request->payment_method == 'paypal') {
|
||||||
|
$order->CodPagamentoGM = '472';
|
||||||
|
}
|
||||||
|
if ($request->payment_method == 'bacs') {
|
||||||
|
$order->CodPagamentoGM = 'BONIFPOSTALE';
|
||||||
|
$order->FlagSospeso = 1;
|
||||||
|
}
|
||||||
|
$order->Spedizioniere = 'GLS';
|
||||||
|
$order->ImportoSpedizione = $request->shipping_total;
|
||||||
|
|
||||||
|
if ($changedest) {
|
||||||
|
$order->CodDestInternet = $request->customer_id;
|
||||||
|
}
|
||||||
|
$order->save();
|
||||||
|
Log::info('Order:' . json_encode($order));
|
||||||
|
|
||||||
|
|
||||||
$orderdetail->Qta = $prodotto['quantity'];
|
|
||||||
$orderdetail->PrezzoLordo = $prodotto['total'];
|
|
||||||
$orderdetail->Enabled = 1;
|
|
||||||
$orderdetail->DataOra = $request->date_created;
|
|
||||||
$orderdetail->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
$customer = Customer::find($request->customer_id);
|
$prodotti = $request->line_items;
|
||||||
$cliente = new Clientegm();
|
foreach ($prodotti as $prodotto) {
|
||||||
$cliente->CodClienteInternet = $customer['id'];
|
$orderdetail = new Orderdetail();
|
||||||
$cliente->Nominativo = $customer['last_name'] . " " . $customer['first_name'];
|
$orderdetail->IdInternet = $request->id;
|
||||||
$cliente->Indirizzo = $customer['billing']->address_1 . " " . $customer['billing']->address_2;
|
$sku = $prodotto['sku'];
|
||||||
$cliente->Citta = $customer['billing']->city;
|
$codifica = false;
|
||||||
$cliente->Cap = $customer['billing']->postcode;
|
if (strlen($sku) > 7 || strpos($sku, 'USATO') === 0) {
|
||||||
$cliente->Provincia = $customer['billing']->state;
|
$codifica = true;
|
||||||
$cliente->Telefono = $customer['billing']->phone;
|
}
|
||||||
$cliente->Email = $customer['billing']->email;
|
if ($codifica) {
|
||||||
$cliente->IdNazione = 227;
|
} else {
|
||||||
$metas = $customer['meta_data'];
|
$orderdetail->CodArticoloGM = intval($prodotto['sku']);
|
||||||
foreach ($metas as $meta) {
|
Log::info('$orderdetail->CodArticoloGM' . $orderdetail->CodArticoloGM);
|
||||||
|
}
|
||||||
|
|
||||||
if ($meta->key == 'cod_fiscale') {
|
Log::info('sku=', $sku);
|
||||||
$cliente->CodiceFiscale = $meta->value;
|
Log::info('Dettaglio Ordine:' . json_encode($orderdetail));
|
||||||
} elseif ($meta->key == 'vat') {
|
|
||||||
$cliente->PIVA = $meta->value;
|
$orderdetail->Qta = $prodotto['quantity'];
|
||||||
|
$orderdetail->PrezzoLordo = $prodotto['total'];
|
||||||
|
$orderdetail->Enabled = 1;
|
||||||
|
$orderdetail->DataOra = $request->date_created;
|
||||||
|
$orderdetail->save();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$cliente->IdInternet = $request->id;
|
|
||||||
$cliente->save();
|
|
||||||
|
|
||||||
if ($changedest) {
|
$customer = Customer::find($request->customer_id);
|
||||||
$clientedest = new Clientegmdest();
|
Log::info('crea Cliente: ' . $customer['last_name'] . " " . $customer['first_name']);
|
||||||
$clientedest->CodDestInternet = $request->customer_id;
|
$cliente = new Clientegm();
|
||||||
$clientedest->Nominativo = $request->shipping['last_name'] . " " . $request->shipping['first_name'];
|
$cliente->CodClienteInternet = $customer['id'];
|
||||||
$clientedest->Indirizzo = $request->shipping['address_1'] . " " . $request->shipping['address_2'];
|
$cliente->Nominativo = $customer['last_name'] . " " . $customer['first_name'];
|
||||||
$clientedest->Citta = $request->shipping['city'];
|
$cliente->Indirizzo = $customer['billing']->address_1 . " " . $customer['billing']->address_2;
|
||||||
$clientedest->Cap = $request->shipping['postcode'];
|
$cliente->Citta = $customer['billing']->city;
|
||||||
$clientedest->Provincia = $request->shipping['state'];
|
$cliente->Cap = $customer['billing']->postcode;
|
||||||
$clientedest->Telefono = $request->shipping['phone'];
|
$cliente->Provincia = $customer['billing']->state;
|
||||||
|
$cliente->Telefono = $customer['billing']->phone;
|
||||||
|
$cliente->Email = $customer['billing']->email;
|
||||||
$cliente->IdNazione = 227;
|
$cliente->IdNazione = 227;
|
||||||
$clientedest->IdInternet = $request->id;
|
$metas = $customer['meta_data'];
|
||||||
$clientedest->save();
|
foreach ($metas as $meta) {
|
||||||
}
|
|
||||||
Log::debug($request->all());
|
|
||||||
Log::info('Inserito ordine');
|
|
||||||
} //end if status
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($meta->key == 'cod_fiscale') {
|
||||||
|
$cliente->CodiceFiscale = $meta->value;
|
||||||
|
} elseif ($meta->key == 'vat') {
|
||||||
|
$cliente->PIVA = $meta->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$cliente->IdInternet = $request->id;
|
||||||
|
$cliente->save();
|
||||||
|
|
||||||
|
Log::info('Cliente:' . json_encode($cliente));
|
||||||
|
|
||||||
|
if ($changedest) {
|
||||||
|
$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->IdInternet = $request->id;
|
||||||
|
$clientedest->save();
|
||||||
|
Log::info('Cliente Dest:' . json_encode($clientedest));
|
||||||
|
}
|
||||||
|
Log::debug($request->all());
|
||||||
|
Log::info('Inserito ordine');
|
||||||
|
} //end if status
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -5991,7 +5998,7 @@ Route::get('/mylinkspao', function (Illuminate\Http\Request $request) {
|
|||||||
Route::get('/handle-article-action-pao/{id}/{action}', function ($id, $action) {
|
Route::get('/handle-article-action-pao/{id}/{action}', function ($id, $action) {
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
ini_set("memory_limit", "512M");
|
ini_set("memory_limit", "512M");
|
||||||
|
|
||||||
if ($action == 'search') {
|
if ($action == 'search') {
|
||||||
// Logica di ricerca dell'articolo
|
// Logica di ricerca dell'articolo
|
||||||
return loadArticleByIdArticle($id);
|
return loadArticleByIdArticle($id);
|
||||||
@@ -6020,4 +6027,3 @@ Route::get('/handle-article-action-pao/{id}/{action}', function ($id, $action) {
|
|||||||
|
|
||||||
|
|
||||||
Route::get('/product/{sku}', [TestPaoController::class, 'getProductBySku']);
|
Route::get('/product/{sku}', [TestPaoController::class, 'getProductBySku']);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user