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);
  }

Creating Definitions




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 January 1, 0001