100, 'page' => $page,'status'=> ["pending","processing","on-hold"]]); $all_orderswoo = $all_orderswoo->merge($orderswoo); $page++; } while($orderswoo->count() > 0); foreach($all_orderswoo as $orderwoo ){ $this->info("Processing order #{$orderwoo->id}..."); $ordergm = AppOrder::where('IdInternet', $orderwoo->id)->latest('DataOra')->first(); if($ordergm){ $this->info("Order #{$orderwoo->id} found in GM, checking status..."); if($orderwoo->status == 'processing'){ $this->info("Order #{$orderwoo->id} is processing, checking if it needs to be completed..."); if($ordergm->EnabledWoo == 1){ $this->info("Order #{$orderwoo->id} needs to be completed, updating WooCommerce..."); $data = [ 'status' => 'completed', ]; $orderwooupdate = Order::update($orderwoo->id,$data); // sum the number updated of order to the log $orderupdated++; } } elseif ($orderwoo->status == 'on-hold'){ $this->info("Order #{$orderwoo->id} is on-hold, checking if it needs to be processed..."); if($ordergm->FlagSospeso == 0) { $this->info("Order #{$orderwoo->id} needs to be processed, updating WooCommerce..."); $data = [ 'status' => 'processing', ]; $orderwooupdate = Order::update($orderwoo->id,$data); // sum the number updated of order to the log $orderupdated++; } } } else{ $this->info("Order #{$orderwoo->id} not found in GM, skipping..."); } } // get the directory actual name and put in the log file $title = '*** SITO DI PRODUZIONE *** '; $log = $title . ' Ordini aggiornati' . "\n"; // check if there are orders to log if($orderupdated > 0) { // Send the email to the admin with the details of the order log Mail::raw($log, function ($message, $orderupdated) { $message->to("log@fioredellavita.it"); //$message->bcc(''); $message->subject("Ordini Aggiornati su GM:" . $orderupdated); }); } } }