Cs-cart developer FAQ

Following are developer FAQ which I created for quick reference.

How to display message notifications (warning, notice etc) ?

fn_set_notification($type, $title, $message, $message_state = ”, $extra = ”)
Note : message_state = ‘K’ doesn’t have css associated with it

How to get config values ?

Registry::get(‘config.http_host’)   // will output “localhost”
Registry::get(‘config.http_path’)  // will output “/cscart” if installed in dir cscart

Handy Contants ?

$config.full_host_name
$config.skin_path

What to do if I want to add a few more custom fields to product ?

You can do this through 2 ways one add a new product feature second add a new column cscart_products table.  First way is obviously the correct way of doing this, but only problem is most of the place features are not retrieved by default with the product info (func : get_product_details), in the latter method you always get the attribute.

How to know the current user ?

$_SESSION[‘auth’][‘user_id’]
to get the userinfo fn_get_user_short_info($_SESSION[‘auth’][‘user_id’])
source : fn.init.php -> fn_init_user()

Does DEBUG_QUERIES work ? if yes how ?

Include the following line in config.local.php and queries will be outputed to your screen.
define(DEBUG_QUERIES, true) ;

How to see last executed query ?

Use the following custom code – working on it, was in my 2.x version

How do I add javascript library and code in a template ?

http://forum.cs-cart.com/topic/14479-how-to-include-external-library-in-scriptstpl/

how do I log ?

Better to use file_put_content as you cannot put any custom text in here.
fn_log_event($type, $action, $data = array())

how to setup smtp gmail ?

http://kb2.cs-cart.com/gmail#3

will update the following soon

how to change breadcrumb

how to create a custom block.

how to autmatically assign a block to a product.

how to change registration success page ?

how to add products to a block ?

how to assign a variable to view ?

how to create your own hooks ?

how to override styles ?
… use inline styles ??

how to create url, is there something like base_url or app_url ?
use fn_url both in php code and smarty tpl
Eg :

how to redirect ?
use fn_redirect

how to override a controller mode.

how to show page not found

Posted in CS-Cart, CS-Cart Addons, MySql, PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

*