Big Spender Posted October 20, 2014 Share Posted October 20, 2014 I am currently hard coding a few things from CC on other areas of a website when outside the CC system - which is okay for this particular website but/// What are the options (if any) to output data from CC? It would be nice to be able to output the data from box.categories.tpl, additionally the shopping cart and session (login/register links) on other non-CC pages. From my experience of attempting this with other software like phpBB it can be quite difficult. Has anyone attempted this? Thanks in advance for any info/help. Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 20, 2014 Share Posted October 20, 2014 CubeCart 5 has code in four places that can respond to outside requests: 'rm' is used by payment gateways but is not restricted to that purpose, 'ajax' is used to deliver the rendered HTML of the shopping basket when an item is added to the cart, 'passkey' is checked for exportable inventory lists and sales reports, and 'accesskey' is checked for digital downloads. I have built several custom sales reports and inventory lists for store owners so that their associates and [something similar to Google listings] can pull these reports on demand. The category list? It is not too far-fetched to add a 'ajax' or 'rm' response to deliver the rendered HTML of the box.catagories.php template. Quote Link to comment Share on other sites More sharing options...
Big Spender Posted October 21, 2014 Author Share Posted October 21, 2014 Hi bsmither - thanks. So which files as a start point should I be looking at for the AJAX method? Would I be GET'ing from a PHP file or fetching from the database? Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 21, 2014 Share Posted October 21, 2014 From CubeCart's perspective, an ajax call is no different than a regular page request. It is only how the browser and the javascript running on it deals with the response from the server. CubeCart's responsibility is to properly identify in some way the expectations of the browser (let's call it a client). When a customer clicks the "Add to Basket" button, the javascript sends the form elements via ajax to CubeCart. Included in the form elements is the key 'ajaxadd'. This is checked by CubeCart's Cart->add() function and if it is present, CubeCart spits out just the HTML of the shopping basket. So, your new ajax request can be made to any file on the server. If it is a PHP file, then the PHP (if properly tied into CubeCart's infrastructure) can query the database and response with (typically) HTML, XML, or a JSON array. In CubeCart files, look at the CubeCart class, loadPage() method. From the client, make the ajax call include _g=rm&type=plugin in the querystring. Near line 213, we see that the type is currently limited to 'gateway'. I know that in CC5214, there will be these new statements, so let's add them:Was: case 'gateway': Now: case 'plugin': foreach ($GLOBALS['hooks']->load('class.cubecart.construct.callback.plugin') as $hook) include $hook; break; case 'gateway': There needs to be more to this, but we can now use the hook to load the plugin code that will fetch, process, and deliver the custom output back to the client. Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 21, 2014 Share Posted October 21, 2014 I also want to comment that _a=plugin or _a=template seems quite promising! Quote Link to comment Share on other sites More sharing options...
Big Spender Posted October 22, 2014 Author Share Posted October 22, 2014 Okay thanks I am going to take a look into this, I am a front end guy though so maybe back with further questions over the coming weeks. Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 22, 2014 Share Posted October 22, 2014 I will enjoy exploring the possibilities with you. Until then... Quote Link to comment Share on other sites More sharing options...
Big Spender Posted October 24, 2014 Author Share Posted October 24, 2014 Just giving more thought to this, do you not think I'm giving too much thought to what I am trying to do and should just manually query the CC database to output the same <ul><li> list and links? I know it's probably not the most elegant solution but saves me amending the CC files. Obviously this wouldn't help for the shopping cart or session, but for the categories I think it would suffice? Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 24, 2014 Share Posted October 24, 2014 I have never found a situation where one must rely on CubeCart code to give you what you want if you know how to formulate what you need from data you can query straight out of the database. There is/was a program that has a wide variety of shipping/packaging/reporting features. It's for CC3/4 and it's a desktop app, not a web app (like MS Access vs phpMyAdmin). It did its thing by directly querying the CubeCart database. The CubeCart database is not so inscrutable as to cause extraordinary difficulties getting an external app to get its results. On the other hand, since the CubeCart code already exists, and it patches everything together, writing a report generator may be easier. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.