Pro Plugin Extension API for Advanced Features

Order Daemon Docs

Pro API

The Order Daemon Pro API extends the core functionality with advanced features, additional rule components, and enhanced debugging capabilities. This documentation covers all Pro-specific endpoints and features.

Base URL and Authentication

Base URL:

/wp-json/odcm-pro/v1/

Authentication: All Pro endpoints require:

  • WordPress REST API authentication (cookies, application passwords, or JWT tokens)
  • manage_woocommerce capability
  • Valid Order Daemon Pro license

Headers:

  • Content-Type: application/json for POST/PUT requests
  • X-WP-Nonce: {nonce} for authenticated requests from admin

Debug Rule API

The Debug Rule API provides comprehensive testing and debugging capabilities for automation rules.

GET /debug-rule/search-orders

Search for orders to use in rule testing.

Parameters:

  • search (string, optional) – Search term for orders (ID, customer name, or email)
  • limit (int, optional) – Maximum results (default: 20, max: 50)

Example Request:

curl "https://yoursite.com/wp-json/odcm-pro/v1/debug-rule/search-orders?search=12345&limit=10" \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response:

{
  "success": true,
  "data": [
    {
      "id": 12345,
      "status": "processing",
      "total": "99.99",
      "total_formatted": "$99.99",
      "currency": "USD",
      "customer": "John Doe",
      "date": "Jan 15, 2026",
      "date_full": "2026-01-15 14:30:00"
    }
  ]
}

POST /debug-rule/test

Test a rule against a specific order with detailed analysis.

Request Body:

{
  "order_id": 12345,
  "rule_data": {
    "trigger": {
      "id": "order_processing",
      "settings": {}
    },
    "conditions": [
      {
        "id": "product_type",
        "settings": {
          "types": ["virtual"],
          "match_all": false
        }
      }
    ],
    "primaryAction": {
      "id": "change_status_to_completed",
      "settings": {}
    },
    "secondaryActions": []
  }
}

Example Request:

curl -X POST "https://yoursite.com/wp-json/odcm-pro/v1/debug-rule/test" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"order_id": 12345, "rule_data": {...}}'

Example Response:

{
  "success": true,
  "data": {
    "matched": true,
    "conditions": [
      {
        "id": "product_type",
        "result": "pass",
        "message": "All products are virtual"
      }
    ],
    "suggestions": ["This rule matched successfully!"],
    "order_details": {
      "id": 12345,
      "status": "processing",
      "total": "99.99",
      "currency": "USD",
      "payment_method": "stripe",
      "customer_id": 456,
      "date_created": "2026-01-15 14:30:00"
    }
  }
}

Integration Examples

JavaScript – Test Rule with Debug API

// Search for orders
const searchOrders = async (searchTerm, limit = 20) => {
    const response = await fetch(
        `/wp-json/odcm-pro/v1/debug-rule/search-orders?search=${searchTerm}&limit=${limit}`,
        {
            headers: {
                'X-WP-Nonce': wpApiSettings.nonce,
                'Content-Type': 'application/json'
            }
        }
    );
    return response.json();
};

// Test a rule against an order
const testRule = async (orderId, ruleData) => {
    const response = await fetch('/wp-json/odcm-pro/v1/debug-rule/test', {
        method: 'POST',
        headers: {
            'X-WP-Nonce': wpApiSettings.nonce,
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            order_id: orderId,
            rule_data: ruleData
        })
    });
    return response.json();
};

// Usage
const orders = await searchOrders('12345');
const testResult = await testRule(12345, {
    trigger: { id: 'payment_complete', settings: {} },
    conditions: [{ id: 'source_gateway', settings: { gateway: 'stripe' } }],
    primaryAction: { id: 'change_status_to_processing', settings: {} }
});

PHP – Feature Detection

// Check if Pro features are available
function is_order_daemon_pro_available() {
    // Check for Pro API endpoints
    $response = wp_remote_get(rest_url('odcm-pro/v1/debug-rule/search-orders?limit=1'), [
        'headers' => [
            'X-WP-Nonce' => wp_create_nonce('wp_rest'),
        ],
    ]);

    return !is_wp_error($response) && $response['response']['code'] === 200;
}

// Check for Pro components
function has_pro_components() {
    $components = odcm_get_rule_components();
    $pro_components = ['payment_complete', 'source_gateway', 'send_email'];

    foreach ($pro_components as $component) {
        if (isset($components[$component])) {
            return true;
        }
    }

    return false;
}

Error Handling

Pro Feature Errors

When attempting to use Pro features without proper entitlement:

{
  "success": false,
  "message": "This feature requires Order Daemon Pro",
  "code": "odcm_premium_blocked",
  "data": {
    "component": "payment_complete",
    "capability_required": "premium"
  }
}

Graceful Fallback

// Handle Pro-only features gracefully
const createRule = async (ruleData) => {
    try {
        const response = await fetch('/wp-json/odcm/v1/rule-builder/rule', {
            method: 'POST',
            headers: {
                'X-WP-Nonce': wpApiSettings.nonce,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(ruleData)
        });

        if (!response.ok) {
            const error = await response.json();
            if (error.code === 'odcm_premium_blocked') {
                // Show upgrade prompt or remove Pro components
                alert('This rule uses Pro features. Please upgrade to Order Daemon Pro.');
                return handlePremiumRequired(ruleData);
            }
            throw new Error(error.message);
        }

        return response.json();
    } catch (error) {
        console.error('Failed to create rule:', error);
        throw error;
    }
};

Best Practices

Feature Detection

  1. Check for Pro API endpoints before using Pro features
  2. Use capability system to determine component availability
  3. Implement graceful fallbacks when Pro features aren’t available
  4. Cache feature detection results for performance

Was this article helpful?

  • Loading...
Table of Contents
  • Loading...