Skip to content

Architecture

CartBay is a namespaced WooCommerce plugin under WPAnchorBay\CartBay\. It uses WooCommerce order objects as recovery sessions, Action Scheduler for background work, WooCommerce email classes for recovery messages, and REST routes for checkout capture, admin analytics, and tests.

BoundaryValue
Plugin filecartbay-abandoned-cart-recovery-for-woocommerce.php
Namespace rootWPAnchorBay\CartBay\
Source rootapp/
REST namespacecartbay/v1
Text domaincartbay-abandoned-cart-recovery-for-woocommerce
Settings optioncartbay_settings
Campaign optioncartbay_campaign_settings
Woo status prefixwc-cartbay-

These are the modules of the free plugin (app/).

ModuleMain filesResponsibility
CoreCore/Plugin.php, Container.php, Installer.php, Settings.php, CheckoutFields.phpBootstrap, hooks, service container, settings normalization, checkout fields.
AdminAdmin/Settings/*, Admin/Wizard/WizardController.phpWooCommerce settings tab, wizard, fields, dashboards, logs, test UI.
APIApi/Routes/*REST route registration and request handling.
RecoveryRecovery/*Capture, abandonment, sequencing, restore, matching, notifications.
EmailEmail/*WooCommerce recovery email classes and shared email behavior.
DataData/SessionRepository.phpWooCommerce order-backed session CRUD.
AnalyticsAnalytics/AnalyticsService.phpPeriod metrics and cached reporting.
UtilsUtils/TokenHelper.php, RateLimiter.php, Logger.phpToken hashing, rate limiting, logging.

CartBay Pro is a separate plugin (cartbay-pro, main file cartbay-pro.php), not an in-place unlock of the free plugin. It ships from wpanchorbay.com under license and is installed alongside the free plugin, which it declares via Requires Plugins.

BoundaryValue
Plugin filecartbay-pro.php
Namespace rootWPAnchorBay\CartBayPro\
Text domaincartbay
RequiresFree plugin installed and active

Pro attaches through the free plugin’s hook seams (see Hooks & Jobs) and gates its features on license validity via LicenseClient::is_valid(). Gating is fail-open: an invalid, expired, or unreachable license never blocks the free plugin’s core recovery flows. Pro’s own modules include License/* (activation, status, checks), Coupon/* (dynamic per-session recovery coupons), and its own Admin/*, Analytics/*, and Api/Routes/* extensions.

  1. cartbay-abandoned-cart-recovery-for-woocommerce.php registers constants and Composer autoloading.
  2. plugins_loaded checks WooCommerce availability.
  3. Plugin::instance()->init() declares HPOS compatibility, registers container services, hooks runtime events, and fires cartbay_loaded.
  4. Activation creates default options, seeds email templates, registers install-time statuses/CPTs, schedules recurring jobs, and flushes rewrites.
  5. Deactivation unschedules recurring CartBay jobs and flushes rewrites.
Checkout consent + email
-> POST /wp-json/cartbay/v1/capture
-> CaptureService
-> SessionRepository creates/updates WooCommerce order session
-> Action Scheduler marks abandoned
-> EmailSequenceService sends recovery email
-> RestoreService rebuilds cart from token link
-> RecoveryMatcher attributes completed order
-> AnalyticsService reports recovery metrics
  • Use WooCommerce CRUD APIs for order/session data.
  • Do not query WooCommerce order tables directly.
  • Use Action Scheduler, not WordPress cron events.
  • Store restore/unsubscribe tokens as hashes.
  • Keep public REST endpoints rate-limited before database work.
  • Keep checkout assets scoped to checkout pages.
  • Keep Pro license-server failures from blocking capture, email, or restore flows (fail-open). Pro
  • CartBay declares HPOS compatibility on before_woocommerce_init.
  • Classic checkout and Block Checkout share the same capture REST endpoint.
  • Restore and unsubscribe use query parameters, not REST routes.
  • wp_mail_succeeded means WordPress accepted mail, not provider-confirmed delivery.
  • The free plugin requires PHP 8.2+ (both the plugin header and Composer); 8.3+ is recommended for development.