Architecture¶
Module overview¶
The plugin is structured around the ModulesProvider singleton which bootstraps all modules on init.
| Module | Class | Responsibility |
|---|---|---|
| Admin settings | Modules\AdminSettings | Settings page, company/account selection |
| CLI | Modules\CLI | WP-CLI commands for manual sync operations |
| Data filters | Modules\DataFilters | WooCommerce hooks for modifying sync data |
| Payment method mapper | Modules\PaymentMethodMapper | Maps WC payment methods to BC payment methods |
| Schedulers | Schedulers\* | Action Scheduler jobs for automated sync |
| Notifications | Notifications\* | Webhook endpoint for incoming BC notifications |
| Extensions | ExtensionsxtensionsProvider | Optional extension hooks |
| Health checks | HealthChecks\ApplicationHealthChecks | Application health status endpoint |
Sync flow¶
sequenceDiagram
participant WC as WooCommerce
participant Idx as Index table
participant AS as Action Scheduler
participant Sync as SyncScheduler
participant BC as Business Central API
WC->>Idx: Order/customer/refund created or updated
Idx-->>AS: Schedule sync job
AS->>Sync: Run sync job
Sync->>BC: POST/PATCH via Guzzle HTTP + OAuth2
BC-->>Sync: 200 OK + GUID/ETag
Sync->>Idx: Mark synced, store bc_guid & bc_etag Database tables¶
Four custom tables are created on plugin activation. All extend ORMModel from barberklingen/base-plugin.
erDiagram
wp_posts ||--o{ bc_order_index : "order_id"
wp_posts ||--o{ bc_refund_index : "order_id"
wp_users ||--o{ bc_customer_index : "customer_id"
wp_posts ||--o{ bc_product_store : "post_id"
bc_order_index {
int id PK
int customer_id
int order_id
varchar bc_guid
varchar bc_etag
tinyint sync
datetime synced_at
datetime stored_at
tinyint lines_created
tinyint no_sync
varchar claim_id
}
bc_refund_index {
int id PK
int order_id
varchar bc_guid
varchar bc_etag
tinyint sync
datetime synced_at
datetime stored_at
tinyint lines_created
tinyint no_sync
varchar claim_id
}
bc_customer_index {
int id PK
int customer_id
varchar bc_guid
varchar bc_etag
tinyint sync
datetime synced_at
datetime stored_at
varchar claim_id
}
bc_product_store {
int id PK
int post_id
varchar bc_guid
varchar bc_item_number
datetime synced_at
} Claiming¶
OrderIndex and RefundIndex use the Claimable trait. Before processing a batch, records are claimed with a unique claim_id so concurrent runs do not double-process the same records. Claims are released after processing (success or failure).