function renderProductCard($product, $t) { if (empty($product)) { return ''; } // Recupera la recensione SmartVibe dal database $db = getDB(); $review = null; $result = $db->query("SELECT * FROM reviews WHERE product_id = " . $product['id'] . " AND is_smartvibe = 1 LIMIT 1"); if ($result && $result->num_rows > 0) { $review = $result->fetch_assoc(); } $badgeMap = [ 'Amazon Choice' => $t['amazon_choice'] ?? 'Amazon Choice', 'Top vendite' => $t['top_seller'] ?? 'Top seller', 'Affiliato' => $t['affiliate_badge'] ?? 'Affiliate', 'Dropshipping' => $t['dropshipping_badge'] ?? 'Dropshipping' ]; $badge = $badgeMap[$product['badge'] ?? ''] ?? $product['badge'] ?? ''; $html = '
'; if ($badge) { $html .= '' . htmlspecialchars($badge) . ''; } $image = $product['image'] ?? 'https://placehold.co/300x300/EAEDED/333?text=Prodotto'; $html .= '' . htmlspecialchars($product['name']) . ''; $html .= '

' . htmlspecialchars($product['name']) . '

'; // ============================================ // PREZZO // ============================================ $html .= '
โ‚ฌ' . number_format($product['price'] ?? 0, 2); if (!empty($product['old_price'])) { $html .= ' โ‚ฌ' . number_format($product['old_price'], 2) . ''; } $html .= '
'; // ============================================ // PRIME // ============================================ if (!empty($product['prime'])) { $html .= '
' . ($t['prime_shipping'] ?? 'Prime | spedizione 1gg') . '
'; } // ============================================ // PULSANTE AGGIUNGI AL CARRELLO // ============================================ $html .= ''; // ============================================ // PULSANTE ACQUISTA SU AMAZON (Affiliazione) // ============================================ if (!empty($product['type']) && $product['type'] === 'affiliate' && !empty($product['affiliate_url'])) { $html .= ''; $html .= ' ' . ($t['buy_on_amazon'] ?? 'Acquista su Amazon'); $html .= ''; } // ============================================ // ๐Ÿ”ฅ PULSANTE RECENSIONE SMARTVIBE (INVECE DELLE STELLE) // ============================================ if ($review) { // Mostra il pulsante con il titolo della recensione $reviewTitle = htmlspecialchars($review['title'] ?? 'Recensione SmartVibe'); $reviewRating = floatval($review['rating'] ?? 4.7); $stars = str_repeat('โ˜…', round($reviewRating)) . str_repeat('โ˜†', 5 - round($reviewRating)); $html .= ''; $html .= ' '; $html .= '๐Ÿ“– ' . $reviewTitle . ''; $html .= ' ' . $stars . ' ' . number_format($reviewRating, 1) . ''; $html .= ''; } else { // Se non c'รจ recensione, mostra un pulsante per generarla $html .= ''; $html .= ' Genera recensione'; $html .= ''; } $html .= '
'; return $html; } SmartVibe.tech - Benvenuto su