Skip to content

Configuration

Required PHP constants

Define these in wp-config.php or via a .env file (using vlucas/phpdotenv in tests):

define( 'BUSINESS_CENTRAL_OAUTH_TENANT_ID',     'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' );
define( 'BUSINESS_CENTRAL_OAUTH_CLIENT_ID',     'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' );
define( 'BUSINESS_CENTRAL_OAUTH_CLIENT_SECRET', 'your-secret-value' );

Obtain these from your Azure App Registration. The app needs the Dynamics 365 Business Central API permission API.ReadWrite.All (application permission, not delegated).

Admin settings

After activating the plugin, go to Business Central in the WordPress admin menu.

Setting Description
Company The BC company to sync with. Fetched from the API via CompaniesClient.
Shipping account G/L account used for shipping line items (shown once a company is selected).

Settings are stored in wp_options via AdminSettings::get_company_id() and AdminSettings::get_shipping_account().

WP-CLI commands

All commands are prefixed wp business-central.

Orders

Command Description
orders export [--limit=N] [--forced=1] Export pending orders to BC
orders unclaim --claim-id=<id> Release a stuck claim on orders
orders remote delete [--mode=all\|empty-only] Delete remote BC orders
index orders Re-index and schedule all unsynced orders

Refunds

Command Description
refunds export [--limit=N] [--forced=1] Export pending refunds to BC
refunds unclaim --claim-id=<id> Release a stuck claim on refunds
refunds remote delete [--mode=all\|empty-only] Delete remote BC refunds
index refunds Re-index and schedule all unsynced refunds

Customers

Command Description
customers remote delete Delete all remote BC customers
index customers Re-index and schedule all unsynced customers

Diagnostics

Command Description
test order-lines --order-id=<id> [--format=table] Dry-run: list order lines that would be synced
test refund-lines --order-id=<id> [--format=table] Dry-run: list refund lines that would be synced