Search code examples
jsonjquery-mobileopencartvqmod

How to get all data in JSON format from OpenCart 1.5.4 using vqmode and jQueryMobile


I'm starting to make a mobile application to my shopping cart opencart 1.5.4 and would like to make all types of operations from the application, ie the customer to have all that I offer in OC, see Categories , the goods, create a new user account, log into the account, add to shopping cart, and finally to pay. but I want to make is native code in the app because I will use the phone functions.

for that reason I need to work around with web services, either nusoap or json (I prefer the latter since oc is designed for use).

I read in other questions OcJoy has a solution for this, but I do not know where to download or buy it.

however, would appreciate someone to give me a light with examples of how to do it.

In another post answered by OcJoy, says to list the products had to modify the code in catalog / controller / product / catalog.php, however, the file does not exist in my OC 1.5.4

I would greatly appreciate help with this situation.


Solution

  • Ok, I would create a xml file with this code...

    <modification>
    <id><![CDATA[JSON infor for APP]]></id>
    <version><![CDATA[0.8]]></version>
    <vqmver><![CDATA[2.3]]></vqmver>
    <author><![CDATA[Jeremy Fisk (jeremyfisk@clear.net.nz)]]></author>
    <file name="catalog/controller/product/category.php">
        <operation>
            <search position="replace" error="log"><![CDATA[$this->response->setOutput($this->render());]]></search>
            <add><![CDATA[if(isset($this->request->get['json'])) {
                echo json_encode($this->data['products']);
                die;
            } else $this->response->setOutput($this->render()); ]]></add>
        </operation>
    </file>
    

    and then save it in the vqmod/xml folder... this means that if you navigate to http://example.com/index?route=product/category&path=26 it will show the page like normal, however if you add the json atribute to the url you will get the json data... the url for this would be http://example.com/index?route=product/category&path=26&json

    This same code could be modified to add json data for the cart, for checkout, for product pages etc etc...

    I trust this is off assistance to you and i look forward to hearing how you get on...

    Regards

    Jeremy