0

How can i remove the validation in opencart 2.0 admin.when creating the new order ?

Here they are using the curl function for validation. Past two days Im searching for it.

can someone suggest me.me. Im struggle with this.

public function api() {
$json = array();

// Store
if (isset($this->request->get['store_id'])) {
    $store_id = $this->request->get['store_id'];
} else {
    $store_id = 0;
}

$this->load->model('setting/store');

$store_info = $this->model_setting_store->getStore($store_id);

if ($store_info) {
    $url = $store_info['ssl'];
} else {
    $url = HTTPS_CATALOG;
}

if (isset($this->session->data['cookie']) && isset($this->request->get['api'])) {
    // Include any URL perameters
    $url_data = array();

    foreach ($this->request->get as $key => $value) {
        if ($key != 'route' && $key != 'token' && $key != 'store_id') {
            $url_data[$key] = $value;
        }
    }

    $curl = curl_init();

    // Set SSL if required
    if (substr($url, 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, $url . 'index.php?route=' . $this->request->get['api'] . ($url_data ? '&' . http_build_query($url_data) : ''));

    if ($this->request->post) {
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->request->post));
    }

    curl_setopt($curl, CURLOPT_COOKIE, session_name() . '=' . $this->session->data['cookie'] . ';');

    $json = curl_exec($curl);

    curl_close($curl);
}

$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput($json);

}

1 Answers1

-2

Let me know create new order from front page store or admin page ? because it will have different script.

in admin side you can see in file admin/controller/sale/order.php you can check this script:

protected function validate() {
    if (!$this->user->hasPermission('modify', 'sale/order')) {
        $this->error['warning'] = $this->language->get('error_permission');
    }

    return !$this->error;
}

you can change to be:

protected function validate() {
    if (!$this->user->hasPermission('modify', 'sale/order')) {
        $this->error['warning'] = $this->language->get('error_permission');
    }

    return true;
}

if you not need to replace your core opencart code, you can use vqmod.

her03
  • 152
  • 4
  • 13
  • yes, my code is for admin side admin/controller/sale/order.php – her03 Feb 16 '15 at 06:21
  • its still validating. I need to remove valadtion – lingowiz Userlingowiz Feb 16 '15 at 06:21
  • Wouldn't be *not calling the `validate()` method at all* better than just do the validation and return `TRUE` even if it should fail? What if the validation itself is executing DB queries - why to execute them at all if we do not care about the result of the validation? You should think more before answering. – shadyyx Feb 16 '15 at 12:58