<?php
require_once __DIR__.'/../app/bootstrap.php';
use App\Core\Response;use App\Core\ShippingEngine;
if($_SERVER['REQUEST_METHOD']==='POST'&&!verify_csrf())Response::json(['ok'=>false,'message'=>'Invalid security token.'],419);
$d=request_data()+$_GET;$q=ShippingEngine::quote(max(0,(float)($d['subtotal']??0)),max(0,(float)($d['weight']??1)),!empty($d['district_id'])?(int)$d['district_id']:null,!empty($d['area_id'])?(int)$d['area_id']:null,!empty($d['vendor_id'])?(int)$d['vendor_id']:null,!empty($d['product_id'])?(int)$d['product_id']:null);
Response::json(['ok'=>true,'quote'=>$q,'formatted_shipping'=>money($q['shipping_charge']),'formatted_total'=>money($q['total'])]);
