te
This commit is contained in:
@@ -6064,6 +6064,26 @@ function showarray($array)
|
|||||||
echo '<pre>' . json_encode($array, JSON_PRETTY_PRINT) . '</pre>';
|
echo '<pre>' . json_encode($array, JSON_PRETTY_PRINT) . '</pre>';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function isKeyPresent($array, $key)
|
||||||
|
{
|
||||||
|
foreach ($array as $item) {
|
||||||
|
if (isset($item['key']) && $item['key'] === $key) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getValueByKey($array, $key)
|
||||||
|
{
|
||||||
|
foreach ($array as $item) {
|
||||||
|
if (isset($item['key']) && $item['key'] === $key) {
|
||||||
|
return $item['value'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null; // If key is not found
|
||||||
|
}
|
||||||
|
|
||||||
Route::get('/aggiornapreorder/{idarticolo}/{postid}', function ($idarticolo, $postid) {
|
Route::get('/aggiornapreorder/{idarticolo}/{postid}', function ($idarticolo, $postid) {
|
||||||
try {
|
try {
|
||||||
// Aggiorna Preorder
|
// Aggiorna Preorder
|
||||||
@@ -6098,8 +6118,11 @@ Route::get('/aggiornapreorder/{idarticolo}/{postid}', function ($idarticolo, $po
|
|||||||
|
|
||||||
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
$found_key_version = array_search('Versione', array_column($variation->attributes, 'name'));
|
||||||
if ($variation->attributes[$found_key_version]->option == 'Nuovo') {
|
if ($variation->attributes[$found_key_version]->option == 'Nuovo') {
|
||||||
if (isset($variation['meta_data']['_wpro_variable_is_preorder'])) {
|
$arrmetadata = $variation['meta_data'];
|
||||||
$ispreorder = $variation['meta_data']['_wpro_variable_is_preorder'];
|
|
||||||
|
$found = isKeyPresent($arrmetadata, '_wpro_variable_is_preorder');
|
||||||
|
if ($found) {
|
||||||
|
$ispreorder = getValueByKey($arrmetadata, '_wpro_variable_is_preorder');
|
||||||
echo "<span class='badge badge-success'>Preorder</span>" . $ispreorder . "<br>";
|
echo "<span class='badge badge-success'>Preorder</span>" . $ispreorder . "<br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user