link "non disponibile"
This commit is contained in:
@@ -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 "<br>";
|
||||
}
|
||||
|
||||
$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'] . "<br>";
|
||||
}
|
||||
}
|
||||
} 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 "<br>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'] . "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($debug)
|
||||
@@ -298,7 +341,7 @@ function showOrdini()
|
||||
|
||||
function showDettOrdini()
|
||||
{
|
||||
$str = "Ordini Woocommerce:" . PHP_EOL;
|
||||
$str = "Ordini Woocommerce:" . PHP_EOL . '<br>';
|
||||
|
||||
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 .= '<br>';
|
||||
}
|
||||
} 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 .= '<a href="' . $article->permalink . '/apimacro/public/aggiornapreorder/' . $article->IdArticolo . '/1/" target="_blank">Imposta in PRE-ORDINE!</a>' . $sep;
|
||||
} else {
|
||||
$myview .= '<a href="' . $article->permalink . '/apimacro/public/aggiornapreorder/' . $article->IdArticolo . '/-1/" target="_blank">Impostalo Non Disponibile</a>' . $sep;
|
||||
}
|
||||
|
||||
echo $myview;
|
||||
|
||||
Reference in New Issue
Block a user