Categories
eBay Integration

eBay Integration – Creating the Plug-In

The latest version of Zen Cart includes a new method of defining plug-ins. Even though it is still being developed, subject to change, and not well documented, I’m using it for my eBay Integration plug-in because it has a big advantage over the older method of defining a plug-in.

In the past, a plug-in’s files were stored in multiple places in the Zen Cart directory structure and some plug-in files actually overwrote existing “core” files. This made updating and maintaining both the plug-in and Zen Cart difficult. The new method puts the plug-in files in one area and offers a cleaner way to upgrade.

Unfortunately, due to some limitations of the plug-in manager, I have had to put some of the eBay Integration files in other locations. But, I have developed the plug-in so that it does not require modifying any of the Zen Cart core files or any of the existing database tables. This will make maintenance and upgrading easier and less risky.

The plug-in is “installed” in the Zen Cart zc_plugins folder in a folder called ebayintegration which contains a folder called v1.0.0 which, obviously, is the version of the plug-in . In that folder is a file called manifest.php which describes the plugin.

<?php

return [
    'pluginVersion' => 'v1.0.0',
    'pluginName' => 'eBay Integration',
    'pluginDescription' => 'eBay Integration for Zen Cart.',
    'pluginAuthor' => 'Roger Smith (sales@jonrocket.com)',
    'pluginId' => 1818, // ID from Zen Cart forum
    'zcVersions' => ['v157'],
    'changelog' => '', // online URL (eg github release tag page, or changelog file there) or local filename only, ie: changelog.txt (in same dir as this manifest file)
    'github_repo' => '', // url
    'pluginGroups' => [],
];
Code language: HTML, XML (xml)

Zen Cart uses the manifest to install and enable the plug-in through the Zen Cart admin Plug-in Manager. As you can see, it defines things like the name of the plug-in, developer, and version number.

Also in the v1.0.0 folder are two subfolders – installer and admin.

The installer folder contains a PHP file called ScriptedInstaller.php. As the name implies, this is code that installs the plug-in. It calls a method to register the eBay Integration administration page and add it to the Zen Cart Tools menu.

The admin folder contains subfolders that mirror the structure under the main Zen Cart admin folder (which you should have renamed). In the admin folder is the code for the eBay Integration administration page, ebayintegration.php.

Under the admin folder is an include folder. As mentioned earlier, this folder mirrors the admin/includes folder in the Zen Cart root folder. So, the includes folder contains folders that define the classes, CSS, images, language, and other stuff used by the plug-in.

I’m not sharing the code, yet, because it is still under construction.