<?php
require_once __DIR__.'/../app/bootstrap.php';
use App\Core\Database;use App\Core\Response;
$id=(int)($_GET['variant_id']??$_POST['variant_id']??0);$pid=(int)($_GET['product_id']??$_POST['product_id']??0);
$row=$id?Database::safeFetchOne('SELECT pv.*,p.name product_name FROM product_variants pv JOIN products p ON p.id=pv.product_id WHERE pv.id=? AND p.status="published" LIMIT 1',[$id]):Database::safeFetchOne('SELECT id product_id,name product_name,sale_price price,stock FROM products WHERE id=? AND status="published" LIMIT 1',[$pid]);
if(!$row)Response::json(['ok'=>false,'message'=>'Product option not found.'],404);Response::json(['ok'=>true,'variant'=>$row]);
