lang | layout | updated_at | title | identifier | order | categories | published | redirect_from | version | ||
---|---|---|---|---|---|---|---|---|---|---|---|
en |
article_with_sidebar |
2017-11-28 00:01 +0400 |
Creating an addon (module) |
ref_G2mlgckf |
100 |
|
true |
|
X-Cart 5.4 and later |
This chapter describes the process of creating a distributable addon (module) for X-Cart 5.
{% toc Table of Contents %}
Before you get started, you will need to choose two identifiers:
- developer ID
- module ID
Your developer ID will tell other programmers that the addon is written by you. It is like your digital name as a developer in X-Cart app store. The following names are reserved by X-Cart team and cannot be used if you are a 3rd-party developer:
- CDev
- XC
- QSL
- Qualiteam
Module ID is basically the name of your addon in the system, e.g. AustraliaPost or ProductFilter. This name must be unique across your other addons under the same developer ID
The identifiers must begin with an uppercase letter and may consist of a maximum of 64 alphanumeric characters.
-
Create a directory
classes/XLite/Module/<YOUR-DEVELOPER-ID>/<YOUR-MODULE-ID>/
inside your installation using your own developer and module IDs instead of the<YOUR-DEVELOPER-ID>
and<YOUR-MODULE-ID>
parts of the path. -
Create
main.yaml
file inside the folderclasses/XLite/Module/<YOUR-DEVELOPER-ID>/<YOUR-MODULE-ID>/
with the following content:version: 5.4.0.0 type: common authorName: 'Your Developer display name' moduleName: 'Example custom addon' description: 'Description plain text' minorRequiredCoreVersion: 0 dependsOn: { } incompatibleWith: { } skins: { } showSettingsForm: false canDisable: true
-
Set your own module description, addon name and addon author in the corresponding fields.
-
After the re-deployment process is over, your module will show up among the installed modules in My Addons area.
![Screenshot 2020-10-12 at 15.42.50.png]({{site.baseurl}}/attachments/ref_G2mlgckf/Screenshot 2020-10-12 at 15.42.50.png)
However, this addon is not activated yet, and you need to enable it before it starts working.
You can download an example of the simplest X-Cart module here:
Here is the list of the field options along with their short descriptions:
-
version (required)
The addon’s version. It should contain four numbers with the point delimiters between them (e.g. 5.4.0.0). {% link "Read more about X-Cart version system here." ref_wUXMKpNm %}
-
type (optional, default type is ‘common’)
The addon’s type. (e.g. common, payment, shipping, skin)
-
authorName (optional, default author name is the ‘author’ value from the module namespace)
The author’s display name (the one that the end user sees)
-
moduleName (optional, default module name is the ‘name’ value from the module namespace)
The addon’s display name. (the one that the end user sees)
-
description (optional)
The description of the addon.
-
minorRequiredCoreVersion (optional, default value is ‘0’)
The minimal minor core version that is required to install the addon (the third number, e.g. if v5.4.1.0 or higher is required, you should input ‘1’)
-
dependsOn (optional, the list is empty by default)
The list of addons, that are required for your addon
-
incompatibleWith (optional, the list is empty by default)
The list of addons, that cannot be active while your addon is enabled (means they are incompatible)
-
skins (optional, the list is empty by default)
-
showSettingsForm (optional, default is false)
Set to ‘true’ if your addon has settings (should be {% link "specified in install.yaml file" ref_4bMGEiAR %})
-
canDisable (optional, default is true)
Set to ‘false’ if you want to remove an option to temporarily disable your addon. Such addons can only be removed/uninstalled completely.
If you want to create the module's distributive pack, you need to:
- Edit your
<X-Cart>/etc/config.php
file and define thedeveloper_mode
option asOn
there. - Go to admin area and click on the My Addons link in the sidebar.
- After that you will see the Pack it icon near each module in My Addons section of the maintenance panel as shown on the screenshot below: ![Screenshot 2020-10-12 at 15.53.33.png]({{site.baseurl}}/attachments/ref_G2mlgckf/Screenshot 2020-10-12 at 15.53.33.png)
- Clicking the icon shown on the screenshot will generate your module's distribution pack.