<?php
    header('Access-Control-Allow-Origin: '.$config->get('site_url'));
    header('Content-Type: application/json');
    header('Access-Control-Allow-Methods: POST');
    header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods, Authorization, X-Requested-With');

    $response           = [];
    if($_SERVER["REQUEST_METHOD"] == "POST") {
        if(isset($_POST['csrf_token']) && $csrf_generator->validate($_POST['csrf_token'])) {
            if(isset($_POST['id']) && !empty($_POST['id'])){
                $id      = (int)$_POST['id'];
                
                $review = $product->getProductReview($id);
                $response = array('status'=>true, 'message'=>'', 'review'=>$review);
                
            }else{
                $response = array('status'=>false, 'message'=>'Lütfen önce yorum seçin.');
            }
        }else{
            $response = array('status'=>false, 'message'=>"Hatalı CSRF Token!");
        }
    }else{
        $response = array('status'=>false, 'message'=>"Hatalı İstek!");
    }

    echo json_encode($response);