Add Google Merchant Center product feed and GSC meta tag placeholder

- merchant-feed.php: RSS 2.0 feed with all active products; includes
  title, description, image_link, price, availability, brand, shipping,
  google_product_category for each item; URL to submit in Merchant Center
- header.php: placeholder GSC meta tag (replace PASTE_GSC_CODE_HERE with
  verification content value from Search Console)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-14 23:01:53 +00:00
parent 873a0962c6
commit b504981b89
2 changed files with 80 additions and 0 deletions
+2
View File
@@ -31,6 +31,8 @@ $customerUser = $isLoggedIn ? CustomerAuth::getUser() : null;
<meta name="description" content="<?= htmlspecialchars($metaDescription ?? "Premium artisan coffee beans freshly roasted and delivered to your door. Shop single origin, blends, and specialty coffee from Tom's Java Jive.") ?>">
<meta name="keywords" content="<?= htmlspecialchars($metaKeywords ?? "artisan coffee, coffee beans, single origin coffee, fresh roasted coffee, Weatherford Texas coffee, specialty coffee") ?>">
<meta name="robots" content="<?= $metaRobots ?? 'index, follow' ?>">
<!-- Google Search Console verification -->
<meta name="google-site-verification" content="PASTE_GSC_CODE_HERE">
<link rel="canonical" href="<?= $canonicalUrl ?? 'https://tomsjavajive.com' . strtok($_SERVER['REQUEST_URI'], '?') ?>">
<meta property="og:type" content="<?= $ogType ?? 'website' ?>">
<meta property="og:site_name" content="Tom's Java Jive">
+78
View File
@@ -0,0 +1,78 @@
<?php
/**
* Tom's Java Jive — Google Merchant Center Product Feed (RSS 2.0 / Atom)
* URL: https://tomsjavajive.com/merchant-feed.php
* Submit this URL in Merchant Center → Products → Feeds
*/
require_once __DIR__ . '/includes/functions.php';
header('Content-Type: application/xml; charset=utf-8');
header('X-Robots-Tag: noindex');
$base = 'https://tomsjavajive.com';
$products = db()->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 '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">' . "\n";
echo '<channel>' . "\n";
echo ' <title>Tom\'s Java Jive</title>' . "\n";
echo ' <link>' . $base . '</link>' . "\n";
echo ' <description>Premium artisan flavored coffee beans, freshly roasted in Weatherford, TX.</description>' . "\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';
$title = htmlspecialchars($p['name'] . ' ' . $categoryLabel . ' Coffee');
$desc = htmlspecialchars(
$p['name'] . ' flavored artisan coffee — ' . strtolower($categoryLabel) . '. ' .
'All natural flavoring. Freshly roasted in Weatherford, TX and shipped to your door. ' .
'12 oz bag.'
);
$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 &amp; Tobacco &gt; Beverages &gt; Coffee';
echo " <item>\n";
echo " <g:id>{$id}</g:id>\n";
echo " <g:title>{$title}</g:title>\n";
echo " <g:description>{$desc}</g:description>\n";
echo " <g:link>{$link}</g:link>\n";
echo " <g:image_link>{$imageLink}</g:image_link>\n";
echo " <g:condition>new</g:condition>\n";
echo " <g:availability>{$avail}</g:availability>\n";
echo " <g:price>{$price} USD</g:price>\n";
if ($salePrice) {
echo " <g:sale_price>{$salePrice} USD</g:sale_price>\n";
}
echo " <g:brand>Tom's Java Jive</g:brand>\n";
echo " <g:google_product_category>{$gCategory}</g:google_product_category>\n";
echo " <g:product_type>Coffee &gt; Flavored Coffee &gt; {$categoryLabel}</g:product_type>\n";
echo " <g:identifier_exists>false</g:identifier_exists>\n";
echo " <g:shipping>\n";
echo " <g:country>US</g:country>\n";
echo " <g:service>Standard</g:service>\n";
echo " <g:price>5.99 USD</g:price>\n";
echo " </g:shipping>\n";
echo " </item>\n";
}
echo '</channel>' . "\n";
echo '</rss>';