<?php  if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } function validateScan(string $code): array { $order=Database::fetchOne("SELECT id,order_ref,status_code FROM orders WHERE order_ref=:ref",[":ref"=>$code]); if(!$order) return ["valid"=>false,"error"=>"Order not found"]; if((int)$order["status_code"]===2007) return ["valid"=>false,"error"=>"Order cancelled"]; $items=Database::fetchAll("SELECT listing_name,qty,unit_price FROM order_items WHERE order_id=:oid",[":oid"=>$order["id"]]); return ["valid"=>true,"order"=>$order,"items"=>$items]; } 