fetchAll( "SELECT p.*, pt.name AS type_name FROM products p LEFT JOIN product_types pt ON p.product_type_id = pt.type_id WHERE p.is_active = 1 ORDER BY p.name, p.category" ); echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo ' Tom\'s Java Jive' . "\n"; echo ' ' . $base . '' . "\n"; echo ' Premium artisan flavored coffee beans, freshly roasted and delivered to your door.' . "\n"; foreach ($products as $p) { $images = json_decode($p['images'] ?? '[]', true); $imageUrl = !empty($images) ? $base . $images[0] : $base . '/assets/images/placeholder-product.svg'; $categoryLabel = $p['category'] === 'Bean' ? 'Whole Bean' : 'Ground'; $grindNote = $p['category'] === 'Bean' ? 'Available as whole bean so you can grind fresh for maximum flavor.' : 'Pre-ground to a versatile medium grind, ready to brew right out of the bag.'; $title = htmlspecialchars($p['name']); $rawDesc = $p['description'] ?? ''; if (!empty($rawDesc)) { $desc = htmlspecialchars( strip_tags($rawDesc) . ' ' . $grindNote . ' 12 oz bag. Ships from Weatherford, TX.' ); } else { $desc = htmlspecialchars( "Tom's Java Jive {$p['name']} flavored artisan coffee, freshly roasted in small batches in Weatherford, Texas. " . "All-natural flavoring with no artificial additives. {$grindNote} " . "12 oz bag. Free shipping on orders over \$50." ); } $link = htmlspecialchars($base . '/product.php?id=' . $p['product_id']); $imageLink = htmlspecialchars($imageUrl); $price = number_format((float)($p['sale_price'] ?? $p['price']), 2, '.', ''); $salePrice = $p['sale_price'] ? number_format((float)$p['sale_price'], 2, '.', '') : null; $avail = (int)$p['stock'] > 0 ? 'in stock' : 'out of stock'; $id = htmlspecialchars($p['product_id']); $updatedAt = substr($p['updated_at'] ?? date('Y-m-d'), 0, 10); // Google product category for flavored coffee // https://www.google.com/basepages/producttype/taxonomy-with-ids.en-US.txt // 2273 = Food, Beverages & Tobacco > Beverages > Coffee $gCategory = 'Food, Beverages & Tobacco > Beverages > Coffee'; echo " \n"; echo " {$id}\n"; echo " {$title}\n"; echo " {$desc}\n"; echo " {$link}\n"; echo " {$imageLink}\n"; echo " new\n"; echo " {$avail}\n"; echo " {$price} USD\n"; if ($salePrice) { echo " {$salePrice} USD\n"; } echo " Tom's Java Jive\n"; echo " {$gCategory}\n"; echo " Coffee > Flavored Coffee > {$categoryLabel}\n"; echo " false\n"; echo " {$categoryLabel}\n"; echo " \n"; echo " US\n"; echo " Standard\n"; echo " 5.99 USD\n"; echo " 1\n"; echo " 2\n"; echo " 3\n"; echo " 7\n"; echo " \n"; echo " default\n"; echo " \n"; } echo '' . "\n"; echo '';