Introduction

Managing multiple WooCommerce stores can be a logistical nightmare when it comes to inventory synchronization. Without proper syncing, you risk overselling, stock discrepancies, and frustrated customers.

In this guide, we’ll cover how to build a real-time inventory sync system between multiple WooCommerce stores using APIs, webhooks, and automation.

Why Real-Time Inventory Sync?

  • Prevent overselling by syncing stock immediately.
  • Manage multiple storefronts (e.g., regional stores).
  • Update warehouse stock instantly after sales.
  • Integrate with ERP or POS systems for unified inventory management.

Tools & Technologies

  • WooCommerce REST API (or GraphQL)
  • Webhooks (woocommerce_update_product, woocommerce_reduce_order_stock)
  • Action Scheduler (for queued syncs)
  • Optional: Redis or database triggers for high-traffic stores
  • ERP/POS integrations (if required)

Step 1: Enable WooCommerce REST API

Each store needs an API key:

WooCommerce → Settings → Advanced → REST API → Add Key

  • Permissions: Read/Write

You’ll get:

  • Consumer Key
  • Consumer Secret

Step 2: Create a Sync Plugin for Store A

Whenever stock changes, push updates to Store B using the REST API.

add_action('woocommerce_product_set_stock', 'sync_inventory_to_other_stores', 10, 1);

function sync_inventory_to_other_stores($product) {
    $product_id   = $product->get_id();
    $stock_qty    = $product->get_stock_quantity();

    $remote_api_url = 'https://store-b.com/wp-json/wc/v3/products/' . $product_id;
    $api_key        = 'ck_xxxxx';
    $api_secret     = 'cs_xxxxx';

    $response = wp_remote_post($remote_api_url, [
        'headers' => [
            'Authorization' => 'Basic ' . base64_encode($api_key . ':' . $api_secret),
            'Content-Type'  => 'application/json'
        ],
        'body' => json_encode(['stock_quantity' => $stock_qty])
    ]);

    if (is_wp_error($response)) {
        error_log('Inventory sync failed: ' . $response->get_error_message());
    }
}

This ensures whenever a product stock updates in Store A, it pushes the change to Store B.

Step 3: Handle Stock Reductions on Orders

Hook into woocommerce_reduce_order_stock to update all connected stores:

add_action('woocommerce_reduce_order_stock', 'sync_stock_after_order', 10, 1);

function sync_stock_after_order($order) {
    foreach ($order->get_items() as $item) {
        $product = $item->get_product();
        sync_inventory_to_other_stores($product);
    }
}

Step 4: Webhook Approach (Alternative)

Instead of polling or hooks, you can use WooCommerce Webhooks:

  • Go to WooCommerce → Settings → Advanced → Webhooks
  • Create a webhook for Product Updated or Order Created
  • Target a custom endpoint in the other store
  • Update inventory in real-time

This is more efficient for large catalogs.

Step 5: Handling Multiple Stores

If you have 3+ stores, create a central inventory service:

  • One API gateway (middleware) to update all stores
  • Each stock update triggers a broadcast to connected stores
  • Use Action Scheduler for queued updates to avoid timeouts

Bonus: ERP or Central Database Sync

For enterprise setups:

  • Sync WooCommerce with ERP (e.g., Odoo, NetSuite, SAP)
  • Let ERP act as the inventory source of truth
  • Use ERP APIs to push stock updates to all WooCommerce stores

Security Best Practices

  • Use HTTPS and API authentication
  • Validate product IDs before syncing
  • Implement rate limits to avoid API overload
  • Log every sync event for debugging