Jump to content

What are the options for outputting CC data on other pages?


Big Spender

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...