diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php
index faf680c5..9ff99fae 100644
--- a/app/CustomFuncPao.php
+++ b/app/CustomFuncPao.php
@@ -20,6 +20,7 @@ use Codexshaper\WooCommerce\Facades\Order;
use Illuminate\Support\Facades\Schema;
define('QTA_IN_PREVENDITA', 10000);
+define('QTA_MINIMA_PER_PREVENDITA', 10000);
function showarray($array)
{
@@ -129,12 +130,12 @@ function setPreOrder($sku, $aggiornapreordine, $debug)
echo "
";
}
+ $idprodotto = $product['parent_id'];
if ($aggiornapreordine === '1') {
$data = [];
$datenow = date('Y-m-d');
- $idprodotto = $product['parent_id'];
if ($idprodotto > 0) {
if ($debug)
@@ -188,6 +189,48 @@ function setPreOrder($sku, $aggiornapreordine, $debug)
echo "Aggiornato Preorder: [ParentId=" . $idprodotto . '] ProdId= ' . $product['id'] . ' ' . $variation['name'] . "
";
}
}
+ } else if ($aggiornapreordine === '1') {
+
+ if ($idprodotto > 0) {
+
+ $variations = Variation::all($product['parent_id']);
+ if ($debug)
+ showarray($variations);
+ for ($i = 0; $i < count($variations); $i++) {
+ $variation = $variations[$i];
+ if ($variation->id == $product['id']) {
+ // convert object into array
+ $data = json_decode(json_encode($variation), true);
+ break;
+ }
+ }
+
+ $data['stock_quantity'] = 0;
+
+ if ($debug) {
+ echo "Data:";
+ showarray($data);
+ }
+
+ $agg = true;
+ $data['meta_data'] = $product['meta_data'];
+ if ($agg) {
+ updateValueByKey($data['meta_data'], $campoPreOrder, 'no');
+ updateValueByKey($data['meta_data'], '_is_pre_order', 'no');
+ }
+
+ if ($debug) {
+ echo "
Dati da Salvare:";
+ showarray($data);
+ }
+
+ $variation = Variation::update($idprodotto, $product['id'], $data);
+
+ if ($variation) {
+ if ($debug)
+ echo "Aggiornato come Non Disponibile : [ParentId=" . $idprodotto . '] ProdId= ' . $product['id'] . ' ' . $variation['name'] . "
";
+ }
+ }
}
} else {
if ($debug)
@@ -298,7 +341,7 @@ function showOrdini()
function showDettOrdini()
{
- $str = "Ordini Woocommerce:" . PHP_EOL;
+ $str = "Ordini Woocommerce:" . PHP_EOL . '
';
try {
$orders = Order::all();
@@ -309,6 +352,9 @@ function showDettOrdini()
$str .= getvalstr("Id", $order->id);
//$str .= getvalstr("DataOra", $order->DataOra);
//$str .= getvalstr("Totale", $order->Totale);
+ $str .= getvalstr("IdInternet", $order->IdInternet, true) . " ";
+ $str .= getvalstr("", $order->CodClienteInternet, true);
+ $str .= '
';
}
} catch (\Exception $e) {
return "Errore showDettOrdini: " . $e->getMessage();
@@ -317,7 +363,8 @@ function showDettOrdini()
return $str;
}
-function showprice($prezzo) {
+function showprice($prezzo)
+{
return ' € ' . number_format($prezzo, 2);
}
@@ -386,6 +433,8 @@ function libriInPrevendita()
if ($qtyinstock < 0) {
$myview .= 'Imposta in PRE-ORDINE!' . $sep;
+ } else {
+ $myview .= 'Impostalo Non Disponibile' . $sep;
}
echo $myview;