<?php
require_once __DIR__ . '/../app/bootstrap.php';
use App\Core\CodeGenerator; use App\Core\Database;
$id=(int)($_GET['id']??0);
$p=$id>0?Database::safeFetchOne('SELECT p.*,v.shop_name FROM products p LEFT JOIN vendors v ON v.id=p.vendor_id WHERE p.id=? AND p.status IN ("published","active","approved") LIMIT 1',[$id]):null;
if(!$p){http_response_code(404);header('Content-Type: text/plain; charset=utf-8');exit('Product not found.');}
header('Content-Type: image/svg+xml; charset=utf-8');
header('Cache-Control: public, max-age=3600');
header('X-Content-Type-Options: nosniff');
echo CodeGenerator::qrSvg(CodeGenerator::productPayload($p),240);
