-1

im trying to insert orders manually through the admin in Opencart 2, so most of these orders will nt have a email address so i need to make the email filed not required at the insert order through admin

but its a bit complex in Opencart 2

i see the below code in add function

if ($this->validate()) {
        // API
        $this->load->model('user/api');

    $api_info = `$this->model_user_api->getApi($this->config->get('config_api_id'));`

    if ($api_info) {
        $curl = curl_init();

        // Set SSL if required
        if (substr(HTTPS_CATALOG, 0, 5) == 'https') {
            curl_setopt($curl, CURLOPT_PORT, 443);
        }

        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLINFO_HEADER_OUT, true);
        curl_setopt($curl, CURLOPT_USERAGENT, $this->request->server['HTTP_USER_AGENT']);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_URL, HTTPS_CATALOG . 'index.php?route=api/login');
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($api_info));

        $json = curl_exec($curl);

        if (!$json) {
            $this->error['warning'] = sprintf($this->language->get('error_curl'), curl_error($curl), curl_errno($curl));
        } else {
            $response = json_decode($json, true);

            var_dump($response);

            if (isset($response['cookie'])) {
                $this->session->data['cookie'] = $response['cookie'];
            }

            curl_close($curl);
        }
    }

at the sale/order controller i dont find any specific form validation when inserting a order other than the above code.

can some one please tell me where can i find the form validation part in opencart 2?

LiveEn
  • 3,193
  • 12
  • 59
  • 104

1 Answers1

1

OpenCart 2.0 uses a catalog side API which is what the code above is referring to (it calls it via cURL). You can find this in /catalog/controller/api/ in the relative .php file, which in your case is order.php. This includes the validation as well as the code to call the model files

Jay Gilford
  • 15,141
  • 5
  • 37
  • 56