This commit is contained in:
paoloar77
2024-07-11 16:14:46 +02:00
parent 0f7ab9da34
commit 44de8a64d2

View File

@@ -2149,7 +2149,8 @@ Route::post('/pao1', function (Request $request) {
dd($request->all()); dd($request->all());
}); });
function updateCreate(Request $request) { function updateCreate(Request $request)
{
// WEBHOOK DA GESTPAY A WOOCOMMERCE // WEBHOOK DA GESTPAY A WOOCOMMERCE
@@ -2168,7 +2169,7 @@ function updateCreate(Request $request) {
($request->status == 'processing' && $request->payment_method == 'wc_gateway_gestpay') || ($request->status == 'processing' && $request->payment_method == 'wc_gateway_gestpay') ||
($request->status == 'processing' && $request->payment_method == 'paypal') || ($request->status == 'processing' && $request->payment_method == 'paypal') ||
($request->status == 'processing' && $request->payment_method == 'test') ($request->status == 'processing' && $request->payment_method == 'test')
) { ) {
$productLogger->addLog('', 'updatecreate: ARRIVATO ORDINE ' . $request->payment_method . ' ' . $request->status); $productLogger->addLog('', 'updatecreate: ARRIVATO ORDINE ' . $request->payment_method . ' ' . $request->status);
$myidInternet = (int) $request->id; $myidInternet = (int) $request->id;
@@ -2251,9 +2252,12 @@ function updateCreate(Request $request) {
$productLogger->addLog('', 'Cerco il customer_id: ' . $CodClienteInternet); $productLogger->addLog('', 'Cerco il customer_id: ' . $CodClienteInternet);
$creatoNuovoCliente = false;
if ($CodClienteInternet > 0) { if ($CodClienteInternet > 0) {
$customer = Customer::find($CodClienteInternet); $customer = Customer::find($CodClienteInternet);
if ($customer)
$creatoNuovoCliente = true;
} else { } else {
$customer = $request; $customer = $request;
$customer['id'] = 0; $customer['id'] = 0;
@@ -2297,7 +2301,9 @@ function updateCreate(Request $request) {
} catch (\Throwable $th) { } catch (\Throwable $th) {
$productLogger->addLog('', 'Errore: ' . $th->getMessage()); $productLogger->addLog('', 'Errore: ' . $th->getMessage());
} }
$cliente->IdInternet = $myidInternet; if ($creatoNuovoCliente) {
$cliente->IdInternet = $myidInternet;
}
$productLogger->addLog('', ' ...fine compilazione campi Cliente' . json_encode($cliente)); $productLogger->addLog('', ' ...fine compilazione campi Cliente' . json_encode($cliente));
$cliente->save(); $cliente->save();