if ($have_attributes) {
$atclass = 'card-product-size';
$attributeHtml = '';
$attr_count = 0;
foreach ($attribute_list as $key => $value) {
if (in_array($value['id'], $product_attributes)) {
++$attr_count;
$name = 'attribute_' . $attr_count;
$options_array = json_decode($value['attribute_values'], true);
$atname = strtolower(trim($value['attribute_name']));
$avlalibale_in = '';
// 🎯 VALID CSS COLORS LIST
$validColors = [
'red','blue','green','black','white','yellow','orange','pink','purple','gray','grey',
'brown','maroon','navy','skyblue','royalblue','lightblue','darkblue',
'lightgreen','darkgreen','seagreen','gold','violet','beige'
];
// Sirf Color attribute ke liye run karega
if ($atname == 'color' || $atname == 'colour') {
if ($store_id == "14209") {
$maxShow = 5;
$count = 0;
$total = count($options_array);
foreach ($options_array as $valRaw) {
$key = strtolower(trim($valRaw));
// normalize
$key = str_replace(['-', '_'], ' ', $key);
$color = 'gray'; // fallback
foreach ($validColors as $vc) {
if (strpos($key, $vc) !== false) {
$color = $vc;
break;
}
}
if ($count < $maxShow) {
$avlalibale_in .= '
';
}
$count++;
}
if ($total > $maxShow) {
$avlalibale_in .= '
+' . ($total - $maxShow) . '';
}
} else {
// Other stores ke liye text values
foreach ($options_array as $valRaw) {
$avlalibale_in .= '
' . trim($valRaw) . '';
}
}
$attributeHtml = '
';
// Ek hi color attribute dikhana hai, isliye loop stop
break;
}
}
}
} else {
$attributeHtml = '';
$atclass = '';
}