Modify your Zen Cart

I installed Zen Cart on a client’s machine…

  1. installation was a breeze

  2. the problem is it is very easily ideifiable as a Zen Cart… which is bad for a professional site. Everything should look home-grown
  3. The client has an existing site which doesn’t really fit with the Zen Cart presentation style. So I have to do a little conversion
  4. There is basically NO DOCUMENTATION so I’m having to look through the source code to figure out how to implement these changes

Here’s my notes on making the switch!

Overview for every page

As is evident from looking at the URLs of any part of the catalog, the “main” page is just index.php, regardless of what the content of the page is. For any particular page it loads, it has a default file it uses for the entire site, which may be overridden by a locally defined file.

Most of these are PHP code only:

  1. includes/application_top.php – this location is one of the only file paths hard-coded into the PHP code. Its companion does NOT use the “includes” name directly but rather a constant define “DIR_WS_INCLUDES”
  2. includes/modules/pages/[PAGE_NAME]/header_php* – defines some of the product-specific queries and settings for variables defined in application_top.php. You can make other files which will get loaded too, if they start with the phrase header_php
  3. main_template_vars.php:

    Define Template Variables picked up from includes/templates/[NAME OF TEMPLATE]/common/main_template_vars.php unless a file exists in the includes/modules/pages/[PAGE_NAME]/ directory to overide. Allowing different pages to have different overall templates.

  4. tpl_main_page.php:

    Define the template that will govern the overall page layout, can be done on a page by page basis or using a default template. The default template installed will be a standard 3 column lauout. This template also loads the page body code from a page named in the variable $body_code.

    (This refers to includes/templates/template_default/common/tpl_main_page.php for the entire site or
    includes/templates/template_default/[PAGE_NAME]/tpl_main_page.php for a specific page )

    …anyway, that’s how it associates the “main_page” attribute with a PHP page in one of those two locations. That content page will determine the contents between the two columns and above the “center” elements such as “new products”.

  5. includes/application_bottom.php – Actually uses a constant define “DIR_WS_INCLUDES” so watch out!

The page ALSO has a main location-

  • includes/languages/english/[TEMPLATE_NAME]/[PAGE_NAME] – or more generally includes/languages/[LANGUAGE]/[TEMPLATE_NAME]/[PAGE_NAME] – defines:
    1. the navbar and heading titles
    2. THE CONTENT!!! Whew! At Last! it’s stored in the variable TEXT_INFORMATION

Including the Static Pages

  • In the demo store there are some mostly-static main content pages under “Information” and “More Information”. Focussing on “More Information.”
  • I have a includes/languages/english/[NEW_PAGE_NAME].php . My first inclination was to assume that this is where the bulk of the information for the page should live.
  • I see files for the "classic" template like languages/english/classic/[NEW_PAGE_NAME].php . I'm thinking this is for styling the same page in different formats for different template. Are these pages required? If I make a template called BLAH in includes/templates/BLAH do I absolutely need to make files for all my content pages in languages/english/BLAH/[NEW_PAGE_NAME].php ?
  • how about includes/modules/pages/[NEW_PAGE_NAME]? It looks like there is only a small file, header_php.php, there. Do I absolutely need something there? what is that area for, besides putting this small file there?
  • I also see a great deal of material in includes/templates/template_default/templates/tpl_[NEW_PAGE_NAME]_default.php. This looks to be the default templates for every module, and therefore every content page, so that I need not define a languages/english/BLAH/[NEW_PAGE_NAME].php for my BLAH template.

So, in summary:

  1. add includes/languages/english/[NEW_PAGE].php for your main content
  2. add includes/languages/english/[TEMPLATE]/[NEW_PAGE].php if you want your page content to be different in that particular template than the default you just defined
  3. add includes/templates/template_default/templates/tpl_[NEW_PAGE]_default.php for your template (not the content)
  4. add includes/modules/pages/[NEW_PAGE]/header_php.php, possibly for your variable settings

Top Header

  • The header is defined in includes/templates/template_default/common/tpl_header.php
  • Default has
    1. Home
    2. Log In/Out
    3. My Account
    4. Cart (if cart nonempty)
    5. Checkout (if cart nonempty)
    6. Logo banner
    7. Error Message (if any)
    8. Info Message (if any)

    These messages are defined in
    includes/languages/english/classic/header.php

  • so to get the “buy your candy today!” and countdown message we could:
    1. add another field to the top- might be a little busy!

  • Need to add top of logo as first element on left- others can slide to right?
  • Or, possibly have cart navigation etc BELOW the original banner art

Bottom Footer

  • includes/modules/footer.php defines a few variables…
  • …which are then displayed by includes/templates/template_default/common/tpl_footer.php
  • Default footer has
    1. Bottom Nav Bar with “Home”
    2. IP address of client ?!
    3. whatever was defined in footer.php, in our case the copyright notice
    4. the END OF THE BIG TABLE !!
    5. Advertising banners
    6. the parse time
  • We should probably put the bottom navigation links in here

Information Panels

Including the new pages:

  • include/filenames.php – defined FILENAME_[NEW_PAGE_NAME] for each page
  • include/languages/english.php – defined BOX_INFORMATION_[NEW_PAGE_NAME]
  • include/modules/sideboxes/more_information.php – added each page to the array using both the above variables

  • includes/modules/sideboxes/information.php
  • includes/modules/sideboxes/more_information.php is by default empty- make sure you add new items AFTER the closing brace of the conditional there!
  • both explicitly stack BOX_INFORMATION* variables together into an array and pass on to templates
  • BOX_INFORMATION* variables defined in both
    • includes/languages/english.php
    • admin/includes/languages/english.php
  • includes/templates/template_default/sideboxes/tpl_information.php – can also replace template_default with other template names
  • includes/templates/template_default/common/tpl_box_default.php – can also replace template_default with other template names
  • Must contain pages from old site:

    1. Custom info
    2. Visit us
    3. About the store

Other Notes

  • to change the titles of the pages:
    • admin/includes/languages/english.php
    • includes/languages/english.php
  • categories box for Zen Cart is at
    includes/modules/sideboxes/categories.php

    • template at includes/templates/template_default/sideboxes/tpl_categories.php
  • category_row.php seems to be only for index, used by
    includes/templates/[TEMPLATE_NAME]/templates/tpl_index_categories.php
    however note that this file is only currently included in the template_default template
  • can you control which pages have which boxes?
    • individual boxes code is in includes/modules/sideboxes/*.php
    • the side boxes use constants defined in includes/languages/[LANGUAGE].php
    • the actual file which renders the boxes is ??
    • if we can find out which file includes the boxes, we will know how it determines
      which boxes run in a given page/template!
    • under which circumstances does
      includes/modules/sideboxes/template_default/[TEMPLATE_NAME]/??? run?

The Plan

Up to now our investigation has been totally speculative and non-invasive. Below we summarize all the changes and the notes:

  1. put all the application-specific PHP routines in a single file, and have it included at the end of application_top.php
    1. initially this will just define small functions which output store-specific strings
    2. Database accessing functions will initially output dummy text
    3. planned functions:
      1. getConnection() gets a vanilla database connection
      2. getSmallPromoText() generates the short text-only version of the current promotion
      3. makeHeaderPromo() incorporates that short text into header HTML
      4. getLargePromo() generates HTML for the larger version of the promotion
      5. getRandomSplash() returns HTML for a random product image, for use in a splash image
  2. copy template fileset; rename and modify color scheme and look and feel
    • for example, templates/blue_strip is the main area for “blue_strip”
    • see also languages/blue_strip for ???
    • see also modules/sideboxes/template_default/blue_strip for ???
  3. change the header:

    1. integrate logo top into left side of header navigation
    2. add call to action to navigation header (if there’s room!)
    3. modify banner design to match non-ZenCart version
  4. change the footer:

    1. eliminate old content
    2. make bottom navigation links to major site areas
    3. add contact info (phone numbers) and bottom stripe
  5. make templates for all static content – for each new mostly-static page create:
    1. includes/modules/pages/[NAME OF PAGE] to define the page-specific variables… which could be a 2-line header_php.php
    2. includes/languages/[LANGUAGE]/[TEMPLATE NAME]/[NAME OF PAGE] which has the actual text of the center pane
  6. include links to static pages in “information” panel
  7. not sure if changing tpl_main_page.php is even necessary!
  8. Make a combined “categories/search” sidebox
  9. Make a new “promotions” sidebox :
    1. uses routines defined in PHP included by application_top.php, above
    2. links to the seasonal items, or the custom items
    3. possibly just hack this as a 0% sale
    4. If there is room, make a text-only version which says the next major holiday and
      text incorporating the number of days remaining… this is to be used in the navigation header

  10. add images for products and categories; populate
    • images should be proportioned to scale down to 100×80
  11. deploy store

13 thoughts on “Modify your Zen Cart

  1. zen cart is setup to be totally customized by the user, and the support forum for zen-cart contains loads of information, tipc and tricks for designing and customizing.

    i would highly recommend you take the information above and contribute it to the zen-cart community to help others, and to help fill in any gaps in the existing online documentation

  2. I may just do that… however since the “Community” is incredibly rude every time I ask a question, I don’t feel very motivated to do it any time soon!

    Even asking for pointers gets a terse instruction to “read the forums,” even if there are no postings which apply to the given question. I’m finding that given my background in PHP and MySQL, it is much faster and less painful to just dig through the source code than get help from those guys.

    Make no mistake: the existing documentation is VERY BAD and the “community” MAKES IT WORSE. It is one of the worst user/developer communities I have ever seen, full of adolescent ego and elites filled with a sense of entitlement!

  3. Thanks 4 this short informative page. Was planning a e-shop using zen-cart n looking ard 4 free template n customizing n found u. Thanks!

  4. Brian, thanks for these hints and pointers, I too am wanting to really modify the LOOK of my zencart. Out of curiousity, may I see the link to the cart you altered?

    Cheers and thanks,

  5. This resource is great. I’m currently installing two Zen Carts, with a third in the wings, and I’ve just found the code to be far more obtuse than I’m used to. It just doesn’t seem to be clearly laid out or documented, although I’m hoping it’ll make more sense as I dig into it more. (My previous ecommerce work used X-Cart, which really spoiled me with how easy they made things by using Smarty.)

  6. Hi Great information, I found you looking for a way to easy populate my Zen cart Shop I already use Os-commerce but like Zen better Do you have a way of easy populiating it as i have over 6000 items in my shop and dont want to do it by hand again…. Any help on this matter would be appreciated.

  7. In order to display additional static content somhow you have to enable it in the admin module route: Configuration: Define Page Status

  8. You are correct that the community of Zencart is more than rude and of very little help. They had rather argue, deny and be a pain in the ass than help anyone. Unfortunately the only way is to wade through it by trial and error. Zencart is very good, but the forum and community sucks. The payoff is that after you have figured it out the hard way, you don’t have to deal with the !@#$%^&*’s

  9. Thanks for the information! I’ve been on the Zen Cart forums for a few months working on my store, and you are right: the people are very snippy. Heaven forbid anyone asks a question that has already been asked. I’ve been looking for ways to make my store not look like a Zen Store, so thank you for writing this.

Leave a Reply