Zen Cart Version Checking in your Plugin

Determining which version of Zen Cart you are running

The function zen_get_zcversion was created for this purpose.

For example, to determine if you’re running Zen Cart 1.5.7 or higher, use

if (function_exists('zen_get_zcversion') && zen_get_zcversion() >= '1.5.7') { 

If you need to check for lower versions, use the defines from includes/version.php.

For example, if your code only runs on Zen Cart 1.5.6, use something like

if (PROJECT_VERSION_MAJOR != '1' && substr(PROJECT_VERSION_MINOR, 0, 3) == '5.6') { 
  // you are running 1.5.6-1.5.6c  
}

In some cases, it might make more sense to use function_exists. For example, in Zen Cart 1.5.8, several functions were renamed. To determine which function to call, rather than checking for the Zen Cart version, you could do something like this:

      if (function_exists('zen_draw_pulldown_products')) {
         echo zen_draw_pulldown_products(...); 
      } else {
         // 1.5.7 and below
         echo zen_draw_products_pull_down(...); 
      }



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 December 5, 2022 by Scott C Wilson (1210cd72).