Architecture: Bootstrap Notes
This short guide explains how the plugin boots, where core responsibilities live, and where integrators should add new behavior.
Bootstrap flow
Section titled “Bootstrap flow”dino-discounts.phpwires activation/deactivation hooks, compatibility flags, and the main plugin bootstrap.includes/Plugin.phpregisters core services (REST, storefront hooks, migrations, assets, admin wiring).- REST controllers are registered under
dino-discounts/v1and gate access throughAbstractController::check_permission(). - Rule evaluation happens through
RulesEngine, which delegates the per-section checks toRuleMatcherand the section evaluators inincludes/Engine/Evaluators/(WhoEvaluator,WhenEvaluator,WhereEvaluator,TriggerEvaluator).
Core domains
Section titled “Core domains”includes/Engine/: rule matching, targeting, reward strategy selection, and runtime guards.includes/Cart/: coupon and coupon-code lifecycle, linking, export, and redemption state.includes/API/: admin and debug endpoints used by the React UI.includes/Storefront/: cart/checkout rendering and runtime storefront behavior.src/components/: admin application UI, rule builder, coupons, preview, and shared controls.
Integrator guardrails
Section titled “Integrator guardrails”- Prefer extending existing services/controllers over introducing new static utilities.
- Add tests for behavior-heavy changes in
tests/Unitbefore moving UI or endpoint wiring. - When changing UI request flows, use
apiFetchand expose explicit user-facing error states. - For complex rule/coupon edits, keep pure transformation helpers small and isolated so they are testable.