InnoShop Documentation

repository·main·Indexed 20 days ago

https://github.com/innocommerce/innoshop

An open-source e-commerce system built on Laravel 12 featuring multi-language and currency support, OpenAI integration, and a modular plugin and theme system. Includes comprehensive guides for InnoShop DevTools, a CLI toolkit used to scaffold, validate, and publish plugins and themes to the official marketplace.

Tokens
42.7K
Snippets
140
Records
198
Agent score
70%

What's inside InnoShop

  1. PageBuilder project structure

    main

    The PageBuilder plugin follows a structured architecture separating controllers, services, and views. Understanding this layout is essential for locating logic and templates:

    • Controllers/Panel/: Contains backend controllers like PageBuilderController.php.
    • Services/: Contains core business logic, including PageBuilderService.php (page construction), ModulePreviewService.php (module previews), and DesignService.php (design services).
    • Routes/panel.php: Defines the backend routes for the plugin.
    • config.json: The main configuration file for the plugin.
    • Public/: Contains static assets (CSS, JS, images).
    • Views/design/: Contains the designer interface templates and scripts.
    • Views/front/: Contains the frontend templates for homepages, pages, and individual modules.
    PageBuilder/
    ├── Controllers/
    │   └── Panel/
    │       └── PageBuilderController.php
    ├── Services/
    │   ├── PageBuilderService.php
    │   ├── ModulePreviewService.php
    │   └── DesignService.php
    ├── Views/
    ├── Public/
    │   ├── css/
    │   ├── js/
    │   └── images/
    ├── Routes/
    │   └── panel.php
    ├── config.json
    └── README.md
  2. InnoShop Overview and Core Features

    main

    InnoShop is an open-source e-commerce system built on Laravel 12. It is designed for global commerce with the following key features:

    • Multi-language & Multi-currency support.
    • AI Integration: Deeply integrated with OpenAI.
    • Extensibility: Features a plugin mechanism and theme template development capabilities.
    • Architecture: High cohesion and low coupling modular design for easy plugin development.
    • UI: User-friendly, intuitive, and responsive design.
  3. InnoShop Distribution Channels

    main

    InnoShop is distributed through two primary channels depending on the target user:

    1. Composer (For Developers):

      • Command: composer create-project innoshop/innoshop
      • Source: Packagist.
      • Setup: Requires initial registration on Packagist and setting up a GitHub webhook for automatic synchronization.
    2. Release ZIP (For Non-Technical Users/Sales):

      • Source: GitHub Releases.
      • Format: innoshop-vX.Y.Z.zip.
      • Generation: Automatically generated by the release.yml workflow upon pushing a new tag.
  4. How PageBuilder's real-time preview and component communication works

    main

    PageBuilder uses a Vue.js-based architecture to synchronize the editor state with the live preview.

    Component Communication

    The module editor communicates with the main application using Vue.js events:

    1. Event Emission: The module editor emits a change event using $emit('on-changed', data) when data is modified.
    2. Event Listening: The main application listens for these changes via @on-changed="moduleUpdated".
    3. Debouncing: A double-debouncing mechanism is used to prevent excessive HTTP requests during rapid editing.

    Real-time Preview Mechanism

    • The preview area uses an iframe to embed the actual frontend page.
    • When changes occur, AJAX requests fetch the rendered HTML for the specific modules from the backend.
    • The preview area's module content is then replaced with the new HTML to provide an instant "What You See Is What You Get" (WYSIWYG) experience.
  5. How PageBuilder architecture works

    main

    PageBuilder is a visual page builder using a Vue.js + Laravel decoupled architecture. It consists of three main layers:

    1. Designer Interface (Vue App): The editor where users manage module editors, drag-and-drop sorting, and style settings.
    2. Preview Area (iframe): Provides real-time visual feedback of the page being built, including responsive previews.
    3. Backend Service (Laravel API): Handles module preview services, data storage, and file management.

    Data flows from Module Definitions (config) $\rightarrow$ Designer (Vue App) $\rightarrow$ Preview Service (Laravel) $\rightarrow$ Frontend Display (Blade).

    ┌─────────────────────────────────────────────────────────────────┐
    │                         PageBuilder 系统架构                      │
    ├─────────────────┬─────────────────┬─────────────────────────────┤
    │   设计器界面     │   预览区        │   后台服务                   │
    │  (Vue App)      │  (iframe)       │  (Laravel API)              │
    │                 │                 │                             │
    │ • 模块编辑器     │ • 实时预览       │ • 模块预览服务               │
    │ • 拖拽排序       │ • 编辑工具栏     │ • 数据存储服务               │
    │ • 样式设置       │ • 响应式预览     │ • 文件管理服务               │
    └─────────────────┴─────────────────┴─────────────────────────────┘
  6. Plugin scaffold file structure

    main

    When using dev:make-plugin, the following directory structure is generated:

    MyPlugin/
    ├── Boot.php                    # Plugin boot class
    ├── config.json                 # Plugin configuration
    ├── fields.php                  # Configuration field definitions
    ├── Controllers/                # Controller directory
    ├── Models/                     # Model directory
    ├── Services/                   # Service classes
    ├── Repositories/               # Repository classes
    ├── Routes/
    │   ├── panel.php              # Admin panel routes
    │   └── front.php              # Frontend routes
    ├── Views/                     # View files
    ├── Lang/
    │   ├── en/
    │   │   ├── common.php
    │   │   ├── panel.php
    │   │   └── front.php
    │   └── zh-cn/
    │       ├── common.php
    │       ├── panel.php
    │       └── front.php
    └── Database/
        └── Migrations/             # Database migrations
  7. PageBuilder frontend view structure

    main

    The frontend views are split into two main directories: design (the editor interface) and front (the actual customer-facing site).

    Designer Interface (Views/design/)

    Used to build the administrative drag-and-drop/editing experience:

    • layouts/: Contains header.blade.php and sidebar.blade.php.
    • scripts/: Contains core logic like app.blade.php, vue-app.blade.php, and iframe-events.blade.php.
    • editors/: Contains specific module editors (e.g., slideshow.blade.php, rich-text.blade.php, product.blade.php).
    • components/: Reusable UI elements like multi-image-selector.blade.php and link-selector.blade.php.

    Frontend Display (Views/front/)

    Used to render the content to the end user:

    • home.blade.php & page.blade.php: Main page templates.
    • modules/: Individual module templates (e.g., slideshow.blade.php, product.blade.php, article.blade.php).
    • partials/: Small reusable pieces like module-edit-buttons.blade.php.
    Views/
    ├── design/
    │   ├── index.blade.php
    │   ├── layouts/
    │   ├── scripts/
    │   ├── editors/
    │   └── components/
    └── front/
        ├── home.blade.php
        ├── page.blade.php
        ├── modules/
        └── partials/
  8. Understand the PageBuilder Module System

    main

    PageBuilder uses a modular architecture where every functional unit is composed of three distinct layers:

    1. Module Definition (ModuleRepo.php): Defines the module's identity, including its code, default configuration, data structures, and icon identifiers.
    2. Module Editor (Vue Component): A visual interface used within the designer to edit parameters and adjust styles.
    3. Module Template (Blade Template): The frontend representation responsible for rendering the module on the live site, including responsive layouts and the editor toolbar.

    This separation allows you to define how a module looks on the frontend independently of how it is configured in the backend designer.

    ┌─────────────────────────────────────────────────────────────────┐
    │                           模块系统架构                            │
    ├─────────────────┬─────────────────┬─────────────────────────────┤
    │   模块定义       │   模块编辑器     │   模块模板                   │
    │  (ModuleRepo)   │  (Vue组件)      │  (Blade模板)                │
    │                 │                 │                             │
    │ • 模块配置       │ • 参数编辑       │ • 前台展示                   │
    │ • 默认数据       │ • 样式设置       │ • 响应式布局                 │
    │ • 图标标识       │ • 实时预览       │ • 编辑工具栏                 │
    └─────────────────┴─────────────────┴─────────────────────────────┘
  9. PageBuilder Editor CSS File Structure and Dependencies

    main

    The editor's styling is modularized into several files. When building or extending the editor, you must respect the dependency order to ensure variables and base styles are available before component-specific styles are applied.

    Dependency Order:

    1. base.css (Base variables and layout)
    2. header.css, sidebar.css, preview.css (Structural UI elements)
    3. components.css, editor-unified.css (Common components and unified editor specs)
    4. Specific editor templates (e.g., left-image-right-text.blade.php)
    base.css
        ↓
    header.css
    sidebar.css
    preview.css
        ↓
    components.css
    editor-unified.css
        ↓
    Specific editor templates
  10. How PageBuilder data flows between components

    main

    Data in PageBuilder moves through a specific pipeline to ensure the designer stays in sync with the frontend preview:

    1. Definition to Designer: Module configurations are loaded from the backend into the Vue application.
    2. Designer to Preview Service: When a user edits a parameter, the Vue app sends the updated data to the Laravel backend.
    3. Preview Service to Frontend: The backend renders the module's HTML based on the new data.
    4. Frontend to Designer: The rendered HTML is sent back and injected into the designer's iframe to show the real-time effect.

    This cycle ensures that what you see in the editor is an accurate representation of the final rendered output.

    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
    │   模块定义   │───▶│   设计器     │───▶│   预览服务   │───▶│   前台展示   │
    │  (硬编码)   │    │  (Vue App)  │    │  (Laravel)  │    │  (Blade)    │
    └─────────────┘    └─────────────┘    └─────────────┘    └─────────────┘
           │                   │                   │                   │
           ▼                   ▼                   ▼                   ▼
    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
    │   模块配置   │    │   模块数据   │    │   渲染数据   │    │   展示数据   │
    │  (JSON)     │    │  (Array)    │    │  (Array)    │    │  (HTML)     │
    └─────────────┘    └─────────────┘    └─────────────┘    └─────────────┘
  11. How the PayPal Payment Plugin works internally

    main

    The plugin integrates with the PayPal Orders API through several coordinated components:

    1. Initialization: Boot.php initializes the plugin and registers hooks for payment processing.
    2. Routing: Routes/front.php defines the frontend routes for payment processing and callback URLs.
    3. Logic & API: Services/PayPalService.php handles the core PayPal API integration (creating requests, processing responses, and validating IPN notifications).
    4. Request Handling: Controllers/PayPalController.php manages the flow of payment processing and incoming callbacks by utilizing the PayPalService.
    5. UI & Localization: Views/payment.blade.php renders the payment form, while the Lang/ directory provides localized strings for the interface.