CS-Cart Ultimate Template Handbook

On this page i’m gonna put all the template stuff someone will need to make a template: different global variables, loops, condition statements and other smarty-related stuff.

Let’s start from different variables:

{$config.skin_path} – the root path of the skin, i.e. cs-cart/skins/myskin/customer
{$config.current_path} or {$config.current_location} – contains path to shop’s homepage
{$config.current_url} – contains the current url
{$config.current_url|fn_url} – get current SEO’d url
{$index_script} – contains the path to index.php (or admin.php if it’s a template for admin page)
{$images_dir} – the /images/ directory of the skin
{$images_dir}/{$manifest.Customer_logo.filename} – this will generate an url to the logo
{$manifest.copyright} – contains the copyright info from the template file manifest.ini
{$manifest.copyright_url} – copyright url from the template file manifest.ini
{if $auth.user_id} – may be used to check if user logged in
{if $hide_advanced_search} – used to check if advanced search is on
{if $location_dir==”blocks/locations/index”} – used to check if it’s home page
{if in_array(1, $auth.usergroup_ids)} – used to check if logged in used belongs to user group with id 1
{$smarty.const.TIME|date_format:”%Y”} – display current year
{$smarty.session.cart.amount} – used to check or output the number of items on the cart
{$smarty.session.cart.display_subtotal} – total price of all
{$smarty.session.cart.products} – an array of products in cart
{$ldelim} – will output the raw { symbol
{$rdelim} – will output }

Useful commands and constructors

{assign var=”product” value=1|fn_get_product_data} – this will set a $product variable with the info of product with id 1. (You may need to enclose this in {capture} to make sure it doesn’t echo any errors if there are)

Template Loops:

{foreach from=0|fn_get_subcategories item=”cat”}…{/foreach} – iterate through categories, if you place another foreach inside of current, it will allow to iterate through child categories too
{$cat.category|escape:html} – outputs category title and escapes html symbols
{assign var=”_cart_products” value=$smarty.session.cart.products|array_reverse:true}
{foreach from=$_cart_products key=”key” item=”p” name=”cart_products”}

– this loop is used to loop through cart items
{foreach from=$product.product_features item=’i’ key=’k’}{if $i.description == “Artist Name”}Design by {$i.value}{/if}{/foreach} – in this example, we output the product feature if it’s title says “Artist Name”

File-related commands:

{include file=”common_templates/search.tpl” hide_advanced_search=true} – includes the file search.tpl (default search template) with hiding the advanced search option
{script src=”js/myscript.js”} – this will place the <script> tag with all the neccessary attributes

Some general dispatch paths:

categories.catalog – catalog view (a list of categories usually displayed with images and a list of subcategories in it)
categories.view&category_id=1 – view category with id=1
pages.view&page_id=1 – display page with id 1
products.search – search page
profiles.add – user registration page
profiles.update – user profiles page
promotions.list – page with promotions

Check if it’s a Home page

{if $smarty.request.dispatch==’index.index’} or
{if $controller == ‘index’}

Enabling {php}{/php} Smarty tag

The allow_php_in_templates boolean in config.local.php in root CS-Cart directory is what makes it work

Connecting between {php}{/php} and template

{php} $product = $this->get_template_vars(‘product’); {/php} – get a variable from template
{php} $this->assign(‘somevar’, ‘value’); {/php} – set a variable in template

Undocumented stuff

To clean thumbnails cache, log in to admin page and add a &ct=1 parameter to any url you are in. This will wipe out the thumbnails and have them regenerated next time you request those images

This page can be found by searching for:

cs cart templateCS-Cart Templatescan not add pictures cs-cartcs-cart javascriptcs-cart templatecs-cart skincs-cart place photo at bottom


  1. Mike says:

    I do not recommend to use the following constuction: “{assign var=”product” value=1|fn_get_product_data}”

    This is a very resource intensive. So it must be done in PHP files and applied to the template.

    Professional CS-Cart developer could make any modules, changes, and fixes for you here: {{ad removed}}

  2. Alex says:

    Exactly. But please don’t post any more ads here 😉

  3. altteam says:

    Thanks for this article, good reference.

  4. Hoko says:

    In Cs-Cart, how can i get the product price value to pass to input field?

  5. Alex says:

    @Hoko, assuming you are on a product template page, you can use any of these values (depending on the case)


    then, there’s $product.discount and $product.list_discount, which you may use too

    it’s a bit tricky to do it yourself, so basically you can copy the existing script located in common_templates/product_data.tpl to a new file, and trim any unnessecary output

  6. Hoko says:

    Thanks, about this tip.

  7. Julie Carlson says:

    I am helping someone with their cs-cart v1. I was able to nav through and figure out most of the back end but am stuck on this one…. The category pages should *not* display category titles. He wants to use his own images via admin instead.

    Category.php lets me hide the title but doing that also hides the assigned top category image. I tried in the other category related php files as well, no dice.

    In theory, I should be able to remove category titles by copying mainbox.tpl and giving it a new name. Then reference the new name in categories.tpl.

    In practice every which way I tried, it bombed. The title can be hidden by removing the title reference from mainbox.tpl. Doing that hides it everywhere though – including product pages.

    Any thoughts would be greatly appreciated!


  8. Alex says:

    Julie, you will need to look at customer/views/categories/view.tpl
    there, on the most bottom is
    {capture name=”mainbox_title”}{$category_data.category}{/capture}

    just remove the $category_data.category and that should make the title be empty

    btw, sometimes you will need to reactivate the theme for the files to recache

  9. How do I get a zero price to display and allow customer to add this as a free product?

    When I set “add zero price to cart”, no price is displayed.

  10. Alex says:

    You will probably need to modify the template for this — most likely it’s in common_templates/product_data.tpl where all the data for the Buy button is generated

  11. Vivek says:

    Please update this post for cs-cart version 4.0.x and also please let know where all smarty constants are declared for cs-cart v4.

    Thanks in advance

  12. haruna says:

    Hi Alex, with reference to julie’s question, I will like to take out the category list and name as well

  13. CS-Market says:

    Thanks a lot for the article. Wait for 4.0.x update.

Leave a Reply