Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencart 2.0 SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data OK

I looked all over the internet and found no answer.

Basically my problem is whenever I try to edit orders and change stores I get the SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data OK in firefox and in chrome I get SyntaxError: Unexpected end of input OK.

Has anyone found a "real" solution for this because I tried all that was suggested but they don't work. From changing the api_id to making a secondary API. And even the .htaccess method.

like image 766
user2242141 Avatar asked Jan 20 '15 18:01

user2242141


3 Answers

I got the same error and found away to fix it:

  1. Login in the backend as admin and go to System > Users > Api
  2. Create a new api with a generated password and make sure it's enabled
  3. Go to your store settings (system > settings > Edit) and open the Option tab
  4. Scroll down till you find the 'checkout'
  5. Where it says 'API User' select the API User you just created
  6. Save the changes and your done!

You'll be able to edit the order status now!

like image 105
Acey_nl Avatar answered Nov 01 '22 10:11

Acey_nl


I happened to have the same update order issue.

If you tried every possible solution found on the Internet, but no one worked, maybe the bug is from your server provider.

In my case, the problem comes from $curl function, which used frequently on opencart 2.0.

You may paste this php file in your admin/controller/sale/ and then type your url :http://YOURDOMAIN.com/admin/controller/sale/test.php

    <?PHP
            echo "a<br/>";
            $curl = curl_init();
      //http://YOURDOMAIN.com testing"

            $aa='Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36 OPR/28.0.1750.48';
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLINFO_HEADER_OUT, true);
            curl_setopt($curl, CURLOPT_USERAGENT, $aa);
            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,  'http://YOURDOMAIN.com/index.php?route=api/login');

            curl_setopt($curl, CURLOPT_POST, true);


            $json = curl_exec($curl);
            echo "server link to http://YOURDOMAIN.com/index.php?route=api/login <br/>";
            echo "Error Message:<br/>";
            print_r(curl_error($curl));
            echo "<br/>";
            echo "Response:";
            echo "<br/>";
            print_r($json);
            echo "<br/>";
            echo "<br/>";
            echo "<br/>";
            echo "<br/>";
            curl_close($curl);
            $curl = curl_init();
        //http://google.com"

            $aa='Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36 OPR/28.0.1750.48';
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLINFO_HEADER_OUT, true);
            curl_setopt($curl, CURLOPT_USERAGENT, $aa);
            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,  'http://google.com');

            curl_setopt($curl, CURLOPT_POST, true);


            $json = curl_exec($curl);
            echo "server lint to http://google.com <br/>";
            echo "Error Message:<br/>";
            print_r(curl_error($curl));
            echo "<br/>";
            echo "Response:";
            echo "<br/>";
            print_r($json);
            curl_close($curl);
       ?>

If your browser message doesn't show this

a server link to http://YOURDOMAIN.com/index.php?route=api/login Error Message:

Response: {"error":"\u8b66\u544a\uff1a\u4e0d\u5339\u914d\u7684\u7528\u6236\u540d\u6216\u5bc6\u78bc\u3002"}

Then you may ask your server provider to help you setting the server, because this means your $curl could not link to your localhost and could not retrieve data from your localhost.

Hope this will help you !!

like image 26
Chi Min Ho Avatar answered Nov 01 '22 10:11

Chi Min Ho


I was able to solve this problem in 3 steps. In my case, i did upgrade my opencart database from 1.5x to 2.x with the standard (out of the box Opencart upgrade). I also had a multistore configuration. I was able to Edit orders once I run the following steps:

  1. Install OC2 (out of the box, no configuration) with the same admin credential as the one used in your legacy database. Export your database and find the place in the dump file (sql) where you have INSERT INTO api values (... line. This is the first command you need to run in you legacy database.

  2. UPDATE setting set value=1 where key = 'config_api_id';

  3. UPDATE store set ssl=url; However, this may not work if you are working on localhost. So for testing, I had to change it to UPDATE store set ssl = 'http://localhost/'; Do not forget the last backslash.

Please notice that you can also perform those operation on the admin user interface.

like image 39
idefis Avatar answered Nov 01 '22 10:11

idefis