Skip to main content

Order Sync Configuration

Configure order synchronization settings for optimal performance and reliability.

Global Settings

Access Settings

Location: WordPress Admin → GSM Middleware → Settings

Sync Schedule

Default Frequency:

# Crontab entry
0 * * * * /usr/bin/php /path/to/wp-content/plugins/gsm-middleware/cron/order-sync.php

Change frequency:

# Every 30 minutes
*/30 * * * * /usr/bin/php /path/to/cron/order-sync.php

# Every 15 minutes (high volume)
*/15 * * * * /usr/bin/php /path/to/cron/order-sync.php

# Every 2 hours (low volume)
0 */2 * * * /usr/bin/php /path/to/cron/order-sync.php

Batch Size

Orders per sync run:

Default: 100 orders

Adjust based on volume:

// High volume (fast server)
define('GSM_ORDER_SYNC_BATCH_SIZE', 200);

// Medium volume
define('GSM_ORDER_SYNC_BATCH_SIZE', 100);

// Low volume or slow server
define('GSM_ORDER_SYNC_BATCH_SIZE', 50);

Configure via Settings UI:

Settings → Performance → Order Sync Batch Size: 100

Timeout Settings

API Timeout:

Default: 30 seconds
Range: 10-300 seconds

PHP Max Execution Time:

// wp-config.php
define('WP_MAX_EXECUTION_TIME', 300);
# php.ini
max_execution_time = 300

Per-Site Settings

Enable/Disable Order Sync

Per site control:

  1. Go to Control Panel
  2. Find the site
  3. Click "Edit"
  4. Toggle "Enable Order Sync"
  5. Save

Or via database:

-- Disable order sync for site ID 5
UPDATE rm_sites
SET orders_sync = 0
WHERE id = 5;

-- Enable order sync
UPDATE rm_sites
SET orders_sync = 1
WHERE id = 5;

Date Filtering

Min Date Modified:

Only sync orders modified after this date.

Use cases:

  • Initial sync: Start from specific date (e.g., go-live date)
  • Catch-up sync: Sync historical orders
  • Skip old orders: Ignore orders before migration

Configure:

UPDATE rm_sites 
SET min_date_modified = '2026-01-01 00:00:00'
WHERE id = 5;

Format: YYYY-MM-DD HH:MM:SS

Skip Test Orders

Skip orders under $1.00:

Default: Enabled (skip test orders)

Configure:

Site Settings → Advanced → Skip orders under $1.00: ☑

Disable for:

  • Donation sites
  • Sites selling low-value items
  • Development/testing

Max Orders Per Run

Limit orders per sync:

Per-site override:

UPDATE rm_sites 
SET max_orders_per_run = 50
WHERE id = 5;

Use cases:

  • Slow sites: Limit to 25-50
  • Fast sites: Increase to 200-500
  • High priority sites: Process more orders

SKU Verification Settings

Blocked Item Statuses

Global setting: Settings → SKU Verification

Comma-separated statuses:

BLOCKED,DISCONTINUED,OBSOLETE

Per-site override:

UPDATE rm_sites 
SET blocked_item_statuses = 'BLOCKED,PENDING'
WHERE id = 5;

SKU Verification Timeout

Business Central OData timeout:

Default: 10 seconds

Increase for large inventories:

define('GSM_SKU_VERIFICATION_TIMEOUT', 30);

Verification Cache

Cache SKU verification results:

Default: 5 minutes

Configure:

define('GSM_SKU_CACHE_TTL', 300);  // 5 minutes

Disable caching (testing only):

define('GSM_SKU_CACHE_TTL', 0);

Kit Configuration

Define Kits

Format: Parent SKU → Component SKUs + Quantities

Add kit definition:

INSERT INTO rm_kits (site_id, parent_sku, child_sku, quantity)
VALUES
(5, 'KIT-BUNDLE-01', 'COMPONENT-A', 2),
(5, 'KIT-BUNDLE-01', 'COMPONENT-B', 1),
(5, 'KIT-BUNDLE-01', 'COMPONENT-C', 3);

Kit Expansion Settings

Zero out parent price:

Default: Enabled (parent price = $0, components get pro-rated price)

Keep parent price:

UPDATE rm_sites 
SET kit_keep_parent_price = 1
WHERE id = 5;

Kit Verification

Verify all components exist:

Default: Enabled (order fails if component SKU not found)

Skip verification (not recommended):

UPDATE rm_sites 
SET kit_skip_verification = 1
WHERE id = 5;

Shipping Configuration

Shipping Method Mapping

Map platform shipping methods to Navision carriers:

Default mappings:

{
"USPS Priority Mail": "USPS",
"USPS First Class": "USPS",
"FedEx 2Day": "FEDEX",
"FedEx Ground": "FEDEX",
"FedEx Overnight": "FEDEX",
"UPS Ground": "UPS",
"UPS 2nd Day Air": "UPS",
"Free Shipping": "USPS",
"Flat Rate": "USPS"
}

Per-site custom mapping:

UPDATE rm_sites 
SET shipping_method_mapping = JSON_OBJECT(
'Custom Shipping Method', 'FEDEX',
'Another Method', 'UPS'
)
WHERE id = 5;

Default Shipping Carrier

Fallback when no mapping found:

Default: "USPS"

Configure:

UPDATE rm_sites 
SET default_shipping_carrier = 'FEDEX'
WHERE id = 5;

Payment Gateway Configuration

Payment Method Detection

Automatic detection for:

  • Stripe
  • PayPal
  • Klarna
  • Sezzle
  • Credova
  • NMI

Custom payment methods:

UPDATE rm_sites 
SET payment_method_mapping = JSON_OBJECT(
'custom_gateway', 'CREDITCARD',
'another_gateway', 'PAYPAL'
)
WHERE id = 5;

Tax Configuration

States to Tax

Global setting: Settings → Tax Configuration

Format: Comma-separated state codes

Example:

CA,TX,FL,NY,PA,IL,OH,GA,NC,MI

Per-site override:

UPDATE rm_sites 
SET states_to_tax = 'CA,TX,FL'
WHERE id = 5;

Tax Line Creation

When to create SALES TAX line:

  • Ship state in configured tax states
  • Order has tax amount > 0
  • Not tax-exempt customer

Combine shipping tax:

Default: Enabled (product tax + shipping tax combined)

Separate shipping tax:

UPDATE rm_sites 
SET separate_shipping_tax = 1
WHERE id = 5;

Error Handling Configuration

Retry Failed Orders

Soft failures (SKU not in middleware):

Default: Auto-retry on next sync

Disable auto-retry:

UPDATE rm_sites 
SET auto_retry_soft_fails = 0
WHERE id = 5;

Error Notifications

Email on order sync failure:

Configure:

Settings → Notifications
☑ Email on order sync errors
Email: [email protected]

Per-site override:

UPDATE rm_sites 
SET error_notification_email = '[email protected]'
WHERE id = 5;

Hold Threshold

Max errors before holding site:

Default: 10 consecutive errors

Configure:

UPDATE rm_sites 
SET error_threshold = 5
WHERE id = 5;

Auto-disable site after threshold:

UPDATE rm_sites 
SET auto_disable_on_errors = 1,
error_threshold = 10
WHERE id = 5;

Logging Configuration

Log Level

Per-site log level:

Options:

  • error - Only errors
  • warning - Errors + warnings
  • info - Errors + warnings + info
  • debug - Everything (verbose)

Configure:

UPDATE rm_sites 
SET log_level = 'debug'
WHERE id = 5;

Log Retention

How long to keep logs:

Default: 30 days

Configure:

define('GSM_LOG_RETENTION_DAYS', 60);

Advanced Configuration

Parallel Processing

Process multiple sites simultaneously:

Default: Sequential (one site at a time)

Enable parallel processing:

# Run multiple instances with SITE_ID env var
SITE_ID=5 php cron/order-sync.php &
SITE_ID=10 php cron/order-sync.php &
SITE_ID=15 php cron/order-sync.php &

Maintenance Window

Auto-skip during Business Central maintenance:

Default: Sunday 19:00 - Monday 04:00 UTC

Cannot be disabled (BC requirement)

Check if in maintenance window:

SELECT 
CASE
WHEN DAYOFWEEK(NOW()) = 1 -- Sunday
AND HOUR(NOW()) >= 19
THEN 'In maintenance window'
WHEN DAYOFWEEK(NOW()) = 2 -- Monday
AND HOUR(NOW()) < 4
THEN 'In maintenance window'
ELSE 'Normal operations'
END as status;

Custom Fields

Capture additional order fields:

BigCommerce custom fields:

UPDATE rm_sites 
SET custom_fields = JSON_OBJECT(
'purchase_order_number', 'po_number',
'delivery_instructions', 'instructions'
)
WHERE id = 5;

WooCommerce meta fields:

UPDATE rm_sites 
SET wc_meta_fields = JSON_ARRAY(
'_billing_vat_number',
'_shipping_delivery_date',
'_order_special_instructions'
)
WHERE id = 5;

Performance Tuning

Database Optimization

Add indexes:

-- Speed up order lookups
CREATE INDEX idx_order_sync ON rm_order(fully_import_from_website, imported, site_id);

-- Speed up SKU verification
CREATE INDEX idx_items_sku ON rm_items(sku, item_status);

-- Speed up error order queries
CREATE INDEX idx_error_orders ON rm_error_orders(order_number, created_at);

Memory Optimization

Increase PHP memory:

// wp-config.php
define('WP_MEMORY_LIMIT', '512M');

Batch smaller groups:

// Process 50 orders at a time instead of 100
define('GSM_ORDER_SYNC_BATCH_SIZE', 50);

API Rate Limiting

Respect platform rate limits:

BigCommerce:

20 requests/second
20,000 requests/hour

WooCommerce:

Depends on server
No built-in limits

Add delays between requests:

define('GSM_API_REQUEST_DELAY', 100);  // milliseconds

Testing Configuration

Test Mode

Enable test mode for site:

UPDATE rm_sites 
SET test_mode = 1
WHERE id = 5;

Effects:

  • Orders not marked as processed on platform
  • No status updates
  • Logs clearly marked as "TEST MODE"
  • Emails not sent

Dry Run Mode

Simulate sync without writing to database:

DRY_RUN=1 php cron/order-sync.php

Output:

[DRY RUN] Would sync 10 orders from BigCommerce Main Store
[DRY RUN] Would verify 45 SKUs
[DRY RUN] Would write 10 orders to database
[DRY RUN] Would update 10 orders on platform

Configuration Presets

High Volume Site

UPDATE rm_sites SET
max_orders_per_run = 200,
log_level = 'error',
auto_retry_soft_fails = 1
WHERE id = 5;

Low Volume Site

UPDATE rm_sites SET
max_orders_per_run = 50,
log_level = 'info',
error_threshold = 3
WHERE id = 5;

Development Site

UPDATE rm_sites SET
test_mode = 1,
log_level = 'debug',
skip_test_orders = 0,
auto_retry_soft_fails = 0
WHERE id = 5;

Next Steps