Mozshops-Plugins is a framework designed to facilitate the creation of custom plugins and themes for Mozshops.store. It provides a streamlined way to design and deploy plugins with customized functionality and themes for online stores.
- Create custom plugins and themes.
- Use familiar Node.js and EJS templating for development.
- Manage and display store data dynamically.
- Easy setup and deployment with CLI commands.
- Node.js: Ensure Node.js is installed on your system.
- NPM: Comes with Node.js installation.
To install the Mozshops-Plugins SDK, run:
npm install mozshops-plugins
To start a new project, use the command:
ms-plugins --init
This will create a new project directory. The directory name will be used as the ID for the theme, so it is important to name it as <project_name>.theme
.
Example:
mkdir my-theme.theme && cd my-theme.theme
ms-plugins --init
Upon initialization, the following files will be created:
- plugin.json: Manifest file for the plugin.
- theme.json: Configuration file for the theme.
An example plugin.json
file:
{
"id": "default.theme",
"name": "plugin",
"version": "1.0",
"type": "theme",
"author": "author",
"description": "Tema claro elegante e moderno para todo o tipo de lojas",
"preview": "/docs/pcontent/default.theme/preview.jpg"
}
An example theme.json
file:
{
"pageRoot": "./views",
"@pages": {
"home": "home.html"
},
"static": "./public/"
}
pageRoot - Directory containing view files @pages.home- Initial page within the views folder static- Directory containing static assets
The SDK uses EJS templating with the following modifications:
- All standard EJS features.
include
is replaced bylink()
.- Use
link_to(asset)
to return the URL of a specific static asset.
Data placeholders for the shop and products can be used as follows:
<h1>Welcome to <%= shop[0].shop_name %></h1>
<p>Description: <%= shop[0].shop_description %></p>
<img src="<%= shop[0].shop_icon %>" alt="Shop Icon">
Below is an example of the data structure provided to templates:
const product = {
id: "rrgggre4rrrf",
product_name: "Sample Product",
product_description: "This is a sample product to test your plugin",
price: "999",
quantity: 10,
product_photos: "/docs/pcontent/default.theme/233392354.jpg"
};
const data = {
id: "bfhhvfhvureure7r",
shop_name: "Test Shop",
shop_description: "Test Shop",
shop_icon: "/docs/pcontent/default.theme/app_icon.jpg",
visits: 19,
products: [product, product, product] // Example array
};
const meta = {
shop: data.id,
name: data.shop_name,
icon: data.shop_icon,
all: [data],
is_auth: {
whatsapp: "860614661",
address: "Maputo"
}
};
module.exports = { meta, shop: [data] };
To publish your plugin, use:
ms-plugins publish
To test the plugin locally:
ms-plugins test <project_id> <http_port>
Example:
ms-plugins test my-theme 3000
To submit your plugin, zip the project files and send them to:
mozinovati@gmail.com
This SDK is licensed under [Your License Name]. Please include the full license text here.
For more details, visit Mozshops.store Documentation.