Beginners guide to Zencart programming

People, who have tried to edit the code of Zencart for the first time, naturally face difficulties to find the right place to put their patches. They end up with hardcoded links, language dependent texts, at the worst case a new database connetion to pull data from database. The same happened to me when I started working with zencart 4 yeas back. So, this is an effort to help people who have just started working with Zencart and lost in the code.

As you might have noticed, Zencart pages are accessed using the GET variable main_page; for example,, which is the url to login page. So whenever you want to edit a page, first check the value of main_page;. I’ll use login as the example throughout the article.

Now that we have decided which page to edit, we need to know what are the files we need to check (the most important question.). Basically lookout for 3 files first:

  1. the page module file at – ROOT_DIRECTORY/includes/modules/pages/login1/header_php.php
  2. the language file at – ROOT_DIRECTORY/includes/languages/english2/login.php
  3. and finally, the template file at – ROOT_DIRECTORY/includes/templates/YOUR_TEMPLATE3/templates/tpl_login1_default.php

1login – This is the vale of the main_page

2engish – This is the current language of the site

3YOUR_TEMPLATE – This is the name of the current template of the site, default is template_default.

  • If you need simple changes like, text change, you should not touch module or template files. Language file is the place where all the texts are defined. If you do not see the message you are looking for in the language file of the page, search it in the common language file at ROOT_DIRECTORY/includes/languages/english.php. Never write hard-coded texts in the module or template file.
  • If you need some cosmetic changes like, moving the email address and password field in the create account form to the top, you should check the template file. You do not need to work on the language or module file.
  • If you need to grab some info from database, process the data and display the result, do the following:
    • Do the logical part like, grabbing info from database and processing the data, in the page module file. After the processing is done, prepare the variables to output in the page.
    • Open the template file and find the place to echo the variables processed in page module file.

This article does not cover many other beautiful features zencart frame work allow, like overriding files, extra configuration files etc. Will try to cover these in later posts.

I always respect the framework of the system I am working with and I ask everybody to do so. This saves lots of coders time. Do not hack a code :)

, , ,

  1. #1 by Mamun on July 17, 2009 - 8:01 am

    As i am Beginner to Zencart programming, This article is very useful for me. thanks

  2. #2 by Imran on July 17, 2009 - 9:23 am

    Thank you mamun. If you need any other help, let me know.

  3. #3 by arunraj.a.k on January 12, 2011 - 11:59 am

    Imran :
    Thank you mamun. If you need any other help, let me know.

    this s so help ful…..

  4. #4 by arunraj.a.k on January 12, 2011 - 12:00 pm

    i just saved for years….

  5. #5 by arunraj.a.k on January 12, 2011 - 12:39 pm

    gr8 work

  6. #6 by Leila on March 14, 2011 - 11:00 am

    Thanks for the article. I had one question: I had a template and few modules installed and now when I try to add any items to my catalogue the whole main window kinda goes blank. Do you have any idea what could have caused it? Thanks.

  7. #7 by Imran on March 15, 2011 - 8:14 am

    Hi Leila,

    There is no specific reason for that. The code needs to be investigated. One thing you can try is enable the PHP error.

    Open ROOT/includes/application_top.php
    Add the following at the top of the file:

    define(‘STRICT_ERROR_REPORTING’, true);

    It should show what errors are making the page blank.


  8. #8 by Leila on March 24, 2011 - 10:50 am

    Thanks Imran,
    Are you on elance by any chance or do you provide your services professionally? I would live to get some help. Let me know and maybe we can work together IA.

  9. #9 by Imran on March 24, 2011 - 2:24 pm

    Emailed you

  10. #10 by Leila on April 3, 2011 - 2:19 am

    Hi Imran could you pls email me again I can’t seem to find it. Sorry.

  11. #11 by Imran on April 3, 2011 - 9:46 am

    Sent again to L i b o u b o u @ h o t m a i l . c o m
    (except the spaces :) )

  12. #12 by David on April 23, 2011 - 3:16 pm

    Hi Imran

    could you tell me how to create custom field in zen cart?. . . please i’m heaving hard time with this.

  13. #13 by rasa on September 4, 2011 - 10:42 am

    Please tell me some way to learn zencart programming

  14. #14 by Imran on September 4, 2011 - 2:02 pm

    Hi Rasa,

    What I have described is a brief explanation of the zencart front end. You can get more help from zencart’s official tutorial and forum.


  15. #15 by Renee Blankenship on February 15, 2013 - 2:49 pm

    Zen Cart™ truly is the art of e-commerce; free, user-friendly, open source shopping cart software. it is easy to install, configure and use. Zen Cart is feature-rich and may be intimidating at first because of all the options, but after a short time of playing around with it.

  16. #16 by asdfgf on May 7, 2013 - 7:02 pm


  17. #17 by asdfgf on May 7, 2013 - 7:02 pm

    asdfgf :

Comments are closed.