Upgrading plugins to work with 1.5.8/PHP 8.0+

Upgrading old Zen Cart plugins to work with Zen Cart 1.5.8

Array Based Language Files

To avoid duplicate define notices from PHP, Zen Cart 1.5.8 uses Array Based Language Files.

If you need to include a language file, the old style of doing so

  $langfile = DIR_WS_LANGUAGES . $_SESSION['language'] . "/modules/order_total/" .  "ot_group_pricing.php";
  include_once ($langfile);

will no longer work for 1.5.8 and above. However, plugin authors may want to make their code compatible with both 1.5.7 and 1.5.8. Here’s one approach:

  $filename = "ot_group_pricing.php"; 
  $old_langfile = DIR_WS_LANGUAGES . $_SESSION['language'] . "/modules/order_total/" .  $filename; 
  $new_langfile = DIR_WS_LANGUAGES . $_SESSION['language'] . "/modules/order_total/" .  "lang." . $filename; 
  if (file_exists($old_langfile)) {
          include_once ($old_langfile);
  } else if (file_exists($new_langfile)) {
     global $languageLoader; 
     $folder = "/modules/order_total/"; 
     $languageLoader->loadExtraLanguageFiles(DIR_FS_CATALOG . DIR_WS_LANGUAGES,  $_SESSION['language'], $filename, $folder);

PHP 8.2 and objects

PHP 8.2 introduces a new restriction which deprecates the use of dynamic properties.

There are two ways to fix this:

  • Change your class to declare and scope all their properties (class member variables) in the class definition. You can see an example of this in includes/modules/order_total/ot_group_pricing.php in how the variables $_check and $code are declared and scoped explicitly in 1.5.8 but not in 1.5.7.

  • Change your class to explictly allow dynamic properties. You can see an example of this in admin/includes/classes/object_info.php - the class declaration is preceded by


This second method should be used sparingly and only in cases where arbitrary properties are possible (as in objectInfo). If the number of properties is fixed and finite, you should simply explicitly declare them in the class. Doing so will protect you from introducing bugs by spelling the name of a property incorrectly (this was the intention of this PHP change, after all.)

PHP 8.2 objectInfo and plugins

As noted above, PHP 8.2 introduces a new restriction which deprecates the use of dynamic properties.

For core modules in admin, the objectInfo class has been extended to explicitly permit dynamic properties.

Plugin developers using custom tables may extend objectInfo to add properties, or rely on objectInfo’s opt-in to dynamic properties . The former technique is shown in the following example from Email Archive Manager:

  class eam_objectInfo extends objectInfo {

Then, in the code body, instead of

$email = new objectInfo($email_sql->fields);


$email = new eam_objectInfo($email_sql->fields);

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 September 28, 2022 by Scott C Wilson (94e6826).