Skip to content

Architecture

Module overview

src/
├── Dixa.php                    # Plugin bootstrap — registers REST routes, boots modules
├── DixaDataGenerator.php       # Builds the customer payload for the REST response
├── API/
│   ├── API.php                 # Façade — instantiates and exposes resource clients
│   ├── APIClient.php           # Guzzle client preconfigured for https://dev.dixa.io/v1/
│   ├── Requests/Models/        # Request models (EndUser, AnonymizationModel, …)
│   └── Resources/
│       ├── Clients/            # EndUsers, Anonymization, CustomerServiceStatus
│       └── Schemas/            # Response schemas (EndUser, ErrorSchema, …)
├── CLI/
│   ├── CLI.php                 # Registers WP-CLI command groups
│   └── Commands/               # Anonymization, Users
├── Data/
│   ├── DixaExporter.php        # create_or_patch helper; tracks export state via user meta
│   ├── DixaCustomer.php        # Customer data mapper
│   ├── DixaOrder.php           # Order data mapper
│   └── …
├── Frontend/
│   └── CustomerServiceStatusShortCode.php  # [dixa-status] shortcode
└── Modules/
    ├── Jobs/CustomerServiceStatus.php      # Action Scheduler job — polls Dixa every 30 min
    └── Watchers/UserWatcher.php            # WooCommerce hooks → async sync via Action Scheduler

Data flow — customer sync

sequenceDiagram
    participant WC as WooCommerce
    participant Watcher as UserWatcher
    participant AS as Action Scheduler
    participant Exporter as DixaExporter
    participant Dixa as Dixa API

    WC->>Watcher: woocommerce_created_customer
    Watcher->>AS: as_enqueue_async_action(dixa/scheduler/create-customer)
    AS->>Exporter: export_customer($customer_id)
    Exporter->>Dixa: POST /endusers (create)
    alt EmailExists / PhoneNumberExists
        Dixa-->>Exporter: error
        Exporter->>Dixa: GET /endusers?email= (lookup)
        Exporter->>Dixa: PATCH /endusers/{id}
    end
    Exporter->>WC: update_user_meta(exported_to_dixa, 1)

Customer service status flow

The CustomerServiceStatus job runs every 30 minutes via Action Scheduler. It calls the Dixa business-hours API and writes the result to the dixa_customer_service_status option, which the [dixa-status] shortcode reads synchronously.

REST API endpoint

Dixa.php registers a single read-only endpoint under wc/v3/dixa/v1/list. Access requires manage_woocommerce capability. See api.md.