Core Modules & Architecture
This document provides a high-level overview of the plugin’s architecture and the purpose of each major directory.
Main Plugin File: edge-store.php
This is the main entry point for the plugin. It is responsible for:
- Including all necessary files (helpers, routes, connectors, etc.).
- Initializing the main
EdgeStoreclass. - Registering core hooks and filters.
Directory Structure
/connectors/
- Purpose: Contains classes that handle direct communication with third-party APIs.
- Key Files:
colourtech-connectorV2.php: Handles API calls to the ColourTech V2 service for order fulfillment.xero-connector.php: Manages authentication and API calls to Xero for creating invoices and bills.zoho-inventory-connector.php: A legacy connector for Zoho Inventory. The primary Zoho logic is now in thezohocrm/directory.
/syncs/ & /sync-resources/
- Purpose: These directories contain the business logic for the various data synchronization processes.
- Key Files:
sync-resources/xero-sync.php: Contains theXeroSyncclass, which orchestrates the process of syncing customers, orders (as invoices), and print costs (as bills) to Xero.sync-resources/zoho-crm-sync.php: The entry point for the Zoho sync, which delegates to theZohoCRMService.syncs/SyncLoader.php&SyncQueueManager.php: A system for managing and scheduling synchronization tasks in the background.
/zohocrm/
- Purpose: A dedicated module for the Zoho CRM integration, following a more structured, service-oriented pattern.
- Key Files:
Services/ZohoCRMService.php: This is the heart of the Zoho integration. It contains all the logic for fetching products and pricelists, decoding SKUs (by callingZohoHelper), and hydrating WooCommerce product objects.Api/ZohoConnector.php: Handles the low-level API communication with Zoho CRM.Models/: Contains classes that represent Zoho CRM objects (e.g.,ZohoProduct,ZohoPriceList).
/helpers/
- Purpose: A collection of helper classes and functions that provide utility methods used throughout the plugin.
- Key Files:
helpers-zoho.php: The Rosetta Stone for the business logic. TheZohoHelperclass contains the critical functions for decoding the structured SKU strings (skuHasPrint,getFormats, etc.). Any developer working on this plugin must understand this file.helpers-xero.php,helpers-colourtech.php: Provide utility functions specific to their respective integrations.helpers-config.php: Functions for accessing configuration values.
/hooks/
- Purpose: Contains files that hook into WordPress and WooCommerce actions and filters to modify default behavior.
- Key Files:
user-registration.php: Integrates with Gravity Forms to assign user roles on registration.woo-shipping-methods.php: Filters available shipping methods based on user roles.order-sync.php: Triggers the synchronization processes when a new order is created.
/custom-fields/
- Purpose: Defines the Advanced Custom Fields (ACF) used in the plugin, primarily for creating the admin-facing options pages.
- Key Files:
site-settings.php: Creates the main “EDGE Sync Dashboard” page with buttons for manual syncs.site-options-*.php: Defines the ACF fields for configuring the credentials and settings for each integration (Xero, Zoho, etc.).
Next: 03 - The Zoho SKU System