OPA Commerce
OPA Commerce is a high-performance, modular WooCommerce extension built for Unifight Gym. It features a custom Design System Engine, unified Product Cards, dynamic Category & Product Sliders, and a fully custom Shop Builder—all designed to seamlessly integrate with Elementor for a premium shopping experience.
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/opareklama/opa-commerce/archive/refs/heads/master.zipOPA Commerce - Project Architecture & Documentation
Repository: https://github.com/opareklama/opa-commerce Core Objective: A modular, high-performance WooCommerce extension built for Unifight Gym. It provides advanced frontend capabilities (Sliders, Shop Builder, Custom Product Cards) with a deeply integrated Design System Engine, entirely managed from the WordPress backend.
1. Architectural Pattern
The plugin uses a strict Object-Oriented (OOP), Namespace-driven (OpaCommerce), and Modular architecture.
- No Global Namespace Pollution: Everything is scoped under
OpaCommerce\. - Centralized Bootstrapping: The main
opa-commerce.phpfile only defines constants and calls the singletonOpaCommerce\Core\Plugin::instance(). - Modularity: Every distinct feature (e.g., Sliders, Product Cards) is separated into its own self-contained folder under
/modules/. - Security First: Strict
defined('ABSPATH')checks on all files, and unified data sanitization through theSettings_Manager.
2. Directory Structure
opa-commerce/
│
├── core/
│ ├── Plugin.php // The main engine. Initializes modules and shortcodes.
│ └── Settings_Manager.php // Centralized CRUD and strict sanitization for ALL plugin settings.
│
├── lib/
│ └── plugin-update-checker/ // (PUC) Handles automatic updates via GitHub.
│
├── modules/ // All independent features live here.
│ ├── Bottom_Bar/
│ ├── Category_Slider/
│ ├── Design_System/ // Generates the global CSS variables.
│ ├── Product_Cards/ // Renders custom product loop cards.
│ ├── Product_Slider/
│ ├── Shop_Builder/ // Overrides the default WooCommerce archive.
│ └── Single_Product/ // Overrides the single product page layout.
│
└── opa-commerce.php // The primary plugin file (Entry point).
3. Core Components
A. Settings Manager (core/Settings_Manager.php)
All data in the plugin is saved under a single WordPress option key: opa_commerce_settings.
- Sanitization Filter: Before data is saved, it passes through
sanitize_settings(). This method explicitly checks array shapes and strips out unapproved data. (Note: Nested arrays likeresponsivestyling are actively processed here). - Usage: Any module can inject the
$settings_managervia Dependency Injection to read values ($this->settings_manager->get('design_system')).
B. The Design System (modules/Design_System)
Acts as the central nervous system for styling. It allows the admin to set global variables (Primary Color, Border Radius, Card Backgrounds, Typography).
- Dynamic CSS Generator: It reads the settings and dynamically generates a block of CSS variables (
:root { --opa-primary: #xxxxxx; }) and injects it into the<head>of the frontend.
C. WooCommerce Overrides
- Shop Builder: Intercepts WooCommerce's default
woocommerce_contentand replaces it with a custom grid, pagination, and layout settings configured in the backend. - Single Product: Hooks into
woocommerce_single_product_summaryto rearrange, hide, or restyle elements (Gallery, Add to Cart, Title, SKU) based on backend toggles.
D. Advanced Sliders (Shortcode Driven)
Both Category Sliders and Product Sliders are built dynamically:
- Users create unlimited sliders in the backend via a Javascript-driven UI (
slider-admin.js). - The UI uses the WordPress Media Uploader for custom fallback images.
- It generates a unique shortcode (e.g.,
[opa_category_slider id="slider_123"]). - The frontend renders them using
Slick Slider, hooking into the specific layout configurations saved for that ID.
4. Development & "Future Proofing" Rules
If giving this codebase to ChatGPT or another developer, enforce these rules to maintain the integrity of the architecture:
- Never use standard WordPress settings fields loosely: Any new setting MUST be added to the
$settings_managermapping and sanitized correctly inSettings_Manager.php->sanitize_settings(). - Strict OOP: No procedural functions outside of the main
opa-commerce.phpfile. Create a class inside a Module, and initialize it insidePlugin.php'sload_modules()method. - Enqueueing Assets: Always enqueue CSS and JS inside the respective Module's class using
wp_enqueue_scriptorwp_enqueue_style. Only enqueue assets on the specific admin pages where they are needed to prevent backend bloat. - JS Data Passing: When passing PHP arrays to JavaScript (like WooCommerce categories), ensure the array is strictly indexed (
array_values()) sowp_localize_scriptcorrectly encodes it as a JS Array, preventing.map()fatal errors. - Updates: The plugin uses GitHub for distribution via YahnisElsts's
plugin-update-checker. The GitHub repository is Public, so no authentication token is required in the code. To release an update, simply bump the version inopa-commerce.phpand push to themasterbranch.