Site icon Hip-Hop Website Design and Development

methods to make customized ajax handler?

i am attempting to make customized ajax handler as a result of the admin-ajax.php is taking to lengthy to deal with ajax requests from 7s to 10s so i google it and mange to do some customized ajax-handler.php like this

<?php
if (is_ajax_request()) {
    if (isset($_POST["action"]) && !empty($_POST["action"])) { //Checks if motion worth exists
        $motion = $_POST["action"];
        change($motion) { //Change case for worth of motion
            case "check": test_function(); break;
        }
    }
}

//Operate to examine if the request is an AJAX request
operate is_ajax_request() {
    return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}

operate test_function()
{
    $response = wc_get_product(1463);
    header('Content material-Kind: utility/json');
    echo json_encode($response);
    die();
}

and that i ship first the response as textual content $response = "check" and the ajax name was taking 300ms however when attempting to name operate from one other file like $response = wc_get_product(1463); it throws an error within the response Deadly error: Name to undefined operate wc_get_product() in C:wampwww....
and i attempted to make customized wordpress ajax handel utilizing this ajaxflow plugin nevertheless it the identical factor so please please how am i able to name the features from one other information and plenty of thanks prematurely for any assist.