Jump to content

How to access cubecart admin functions from custom php file?


Manik

Recommended Posts

Hi, 

 

I am developing a plugin for cubecart admin panel.In that am using ajax to store some details through database.I have included the admin core files but still its not stored in database. can anyone know, what are all the exact files needed to be included in custom php file to access all the functions of an admin panel?

 

Here is my code. I have tried like this.

but its not allowing me to perform db operations.can any one help me please.am new to cubecart.
<?php
include '../../../../ini.inc.php';
include '../../../../includes/global.inc.php';
include '../../../../includes/functions.inc.php';
include '../../../../classes/db/database.class.php';
include '../../../../controllers/controller.admin.pre_session.inc.php';
$action=$_POST['action'];
$data=array(
'color'=>$_POST['colorname'],
'colorcode'=>$_POST['colorcode'],
);
$res=Database::getInstance()->insert('abc', $data);
$GLOBALS['db']->insert('abc',$data)

Link to comment
Share on other sites

Hi Staff,

 

Thanks For your reply.

I already viewed that article. But I want to do some operations in admin panel dynamically as same as when we try to add or remove zones in for plugin.I am trying to create a form in my plugin and want to submit and update the page using jquery and ajax.In my ajax file, it needs some configuration files included it.this is what am trying.

I have a form like add zone.

if i click that, it will open a form and when i save, it has to add in admin panel and also insert in db as well. for inserting into db, I need some files to be included in my ajax file.

I am new to cubecart. I don't know much about core ffiles. please help me.

Link to comment
Share on other sites

You can still do this with a plugin. Honestly its the best way as the store can be upgraded to the latest version without affecting the plugin. The route you are trying to take right now is complex and has a lot of room for errors. 

 

You'll see that there are a number of plugin hooks already. If you need to add more hooks to the core code of CubeCart please feel free, lets us know what ones you have added and so long as they are not in code loops we will add them to the next release. 

Link to comment
Share on other sites

Okay. can you give me a little example.

 

I have a form in plugin, and i want to submit that to database.I don't know how to do this? so only I tried to do this using ajax. If you give me a example code to submit in plugin form itself and i will understand easily. I don't know much about hooks also, please guide me.

Link to comment
Share on other sites

Its submitted from admin panel only. For example, I am going to provide users to enter some text in products (if am selling CAP means, I provide option to users to enter text in front end).In front end I have some limitations, user has to enter only limited char and based on that price also get varies. to configure all this in front end, i need a form should be submitted by admin in admin panel.

Link to comment
Share on other sites

Ok in that case its all explained here: 

https://support.cubecart.com/index.php?/Knowledgebase/Article/View/203/46/how-can-i-create-a-plugin-using-the-code-hooks-system-in-cubecart-v5

 

It explains how to add an extra item to the navigation menu and get it loading a custom section in the admin CP. Why don't you use the example code and adapt it to your needs?

Link to comment
Share on other sites

Its giving a idea about, developing a simple plugin.I read this article, based on this only am developing.but in this article, they didn't mention about submitting a form from tpl file.In the example visitor status plugin, the have textboxes and that submitted to database. but that data's are stored in configuration table.I want that form details should stored in custom tables.Tell me where can I able to get the post values in that form? I am asking about which file I need to edit and which hook I have to use? please guide me. Its little bit complicated.


I want to add a form in my plugin tpl file like this,

 

http://www.amitpatil.me/demos/adding-removing-rows-in-table-dynamically/#

 

It should added to database and also dynamically added in that plugin tpl file as well...

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...