This commit is contained in:
paoloar77
2024-12-20 17:43:10 +01:00
parent 7d3b2a6b5a
commit 83202a4c24

View File

@@ -32,7 +32,7 @@ use Illuminate\Support\Facades\Request;
define('QTA_IN_PREVENDITA', 10000);
define('QTA_MINIMA_PER_PREVENDITA', 9000);
define('CAMPO_PREORDINE','_ywpo_preorder');
define('CAMPO_PREORDINE', '_ywpo_preorder');
setlocale(LC_TIME, 'it_IT.UTF-8');
@@ -955,6 +955,21 @@ function showprice($prezzo)
}
}
function findInsideProduct(array $prodotto, string $miocampo): ?string
{
if (!isset($prodotto['meta_data']) || !is_array($prodotto['meta_data'])) {
return null;
}
foreach ($prodotto['meta_data'] as $meta) {
if ($meta['key'] === $miocampo) {
return $meta['value'];
}
}
return null;
}
function getRigaArticoloByArt($article, $ind, $sep)
{
@@ -993,6 +1008,9 @@ function getRigaArticoloByArt($article, $ind, $sep)
}
}
$preorder = findInsideProduct($prodotto, CAMPO_PREORDINE);
$preorder_attivato = $preorder === 'yes';
// echo '[' . $ind . ']' . $sep . $mydatestr . $sep . $article->IdArticolo . $sep . $article->Titolo . $sep . $article->DescrizioneStatoProdotto . $sep . $article->DescrizioneFormato . ' [Quantita = ' . $article->QtaDisponibile . ']';
$myview = '[' . $ind . ']' . $sep .
'<a href="' . $article->permalink . '?id=' . $article->IdArticolo . '" target="_blank">' . $article->IdArticolo . '</a>' . $sep .
@@ -1004,7 +1022,7 @@ function getRigaArticoloByArt($article, $ind, $sep)
' [' . showprice($prezzo) . ' ]' . $sep .
'[In Stock = <span style="color:' . $colore . '; font-weight: bold;">' . $qtyinstock . '</span>]' . $sep;
if ($qtyinstock < QTA_MINIMA_PER_PREVENDITA) {
if (!$preorder_attivato || $qtyinstock < QTA_MINIMA_PER_PREVENDITA) {
$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;
@@ -1015,14 +1033,13 @@ function getRigaArticoloByArt($article, $ind, $sep)
if ($prodotto) {
if (isset($prodotto[CAMPO_PREORDINE])) {
$str .= '<br><span style="color:red">PREORDINE: ' . $prodotto[CAMPO_PREORDINE] . '</span>';
}
if (isset($prodotto['_wpro_label_variable'])) {
$str .= 'Etichetta: ' . $prodotto['_wpro_label_variable'];
}
if (isset($prodotto['_wpro_date_variable'])) {
$str .= 'Data Preordine: ' . $prodotto['_wpro_date_variable'];
$datepreorder = findInsideProduct($prodotto, '_ywpo_for_sale_date');
if ($preorder_attivato) {
$str .= ' <span style="color:green">PREORDINE ATTIVO! </span>';
if ($datepreorder) {
$str .= ' <span style="">Data PreOrdine: ' . $datepreorder . '</span>';
}
}
$str .= '<br>';
}
@@ -1033,6 +1050,7 @@ function getRigaArticoloByArt($article, $ind, $sep)
return $str;
}
function showCartolibri()
{
$articles = getArticoliCartolibro();