Template Overrides System

What’s the best way to change a template?

Before you read this, please review basic terms, template default and default files and overrides for new users.

Introduction

Overrides were created to simplify upgrading and templating.

What Can I Override?

Files under a folder with the name of your template

Any file which exists in a folder which has a classic subfolder can be overridden by creating a folder with the name of your template, and copying the file in there.

As of Zen Cart 1.5.6, this list is:

includes/languages/
includes/languages/english/extra_definitions/
includes/languages/english/
includes/languages/english/html_includes/
includes/languages/english/modules/payment/
includes/languages/english/modules/shipping/
includes/languages/english/modules/order_total/
includes/modules/
includes/modules/sideboxes/

In addition, you can override:

includes/index_filters/ 

As an example of this, if your template is called bootstrap, then to override includes/modules/category_row.php, you would create includes/modules/bootstrap/category_row.php.

You can also override any folder in your template folder. Again as of 1.5.6, this list is:

YOUR_TEMPLATE/buttons/
YOUR_TEMPLATE/common/
YOUR_TEMPLATE/css/
YOUR_TEMPLATE/images/
YOUR_TEMPLATE/info_shopping_cart/
YOUR_TEMPLATE/jscript/
YOUR_TEMPLATE/popup_attributes_qty_prices/
YOUR_TEMPLATE/popup_coupon_help/
YOUR_TEMPLATE/popup_cvv_help/
YOUR_TEMPLATE/popup_image/
YOUR_TEMPLATE/popup_image_additional/
YOUR_TEMPLATE/popup_search_help/
YOUR_TEMPLATE/popup_shipping_estimator/
YOUR_TEMPLATE/sideboxes/
YOUR_TEMPLATE/templates/

As an example of this, if your template is called bootstrap, then to override includes/templates/template_default/templates/tpl_product_info_display.php you would create includes/templates/bootstrap/templates/tpl_product_info_display.php.

Files in Other Places

You can also place overrides in these folders:

includes/auto_loaders/overrides/
includes/init_includes/overrides/
admin/includes/auto_loaders/overrides/
admin/includes/init_includes/overrides/

As an example of this, to override admin/includes/init_includes/init_admin_auth.php, you would create admin/includes/init_includes/overrides/init_admin_auth.php.

What Can I NOT Override?

At the moment, these folders of your cart do not support overrides:

  • admin (except in the auto_loaders and init_includes folders, as noted above)
  • includes/modules/pages (but you can add more files to a page’s folder. See the header_php.php Program Flow developer documentation)
  • The shipping, payment and order total folders under includes/modules

However, you may still modify their operation without changing core code by using notifiers and the other mechanisms described below.

Other Mechanisms for Changing Cart Appearance

Some behaviors are controlled by the show flags in the admin.

Starting in 1.5.8, there are site specific overrides, which allow you to change some aspects of Zen Cart without touching core files.

There are also other mechanisms to allow you modify the behavior of the system without touching core files. These are more advanced topics, intended for developers.

See also plugin tips for more suggestions.

Using your Overrides

You’ve created some overrides and now you want to use your new template!

Just create the template_info.php file and activate your template. See the template_info FAQ.

Next Steps




Still have questions? Use the Search box in the upper right, or try the full list of FAQs. If you can't find it there, head over to the Zen Cart support forum and ask there in the appropriate subforum. In your post, please include your Zen Cart and PHP versions, and a link to your site.

Is there an error or omission on this page? Please post to General Questions on the support forum. Or, if you'd like to open a pull request, just review the guidelines and get started. You can even PR right here.
Last modified June 25, 2023 by Chris Brown (7e655b32).