Why WooCommerce + SAP B1 Integration?

WooCommerce is the most widely deployed e-commerce platform in the world. SAP Business One is the ERP of choice for thousands of growing product businesses. When these two systems run independently, your team ends up manually re-entering orders, stock levels fall out of sync, and customer records diverge between systems.

A well-built integration eliminates all of this: WooCommerce orders flow automatically into SAP B1 as Sales Orders, inventory levels update in real time on your store, and customer records stay consistent across both systems.

What we'll cover: This guide walks through the complete architecture of a production-grade WooCommerce ↔ SAP B1 integration, based on integrations our team has built for real clients. The technology stack is WooCommerce REST API + ASP.NET Core middleware + SAP B1 Service Layer.

Step 1: Choosing Your Integration Approach

Before writing a single line of code, you need to make the most important architectural decision: how will data flow between WooCommerce and SAP B1?

There are two fundamental directions:

  1. WooCommerce → SAP B1 (Order flow): New orders placed on WooCommerce are automatically created as Sales Orders in SAP B1. This is always required.
  2. SAP B1 → WooCommerce (Inventory & price flow): Stock levels and item prices from SAP B1 are pushed back to WooCommerce product listings. This is required if your primary inventory management lives in SAP B1.

Most implementations need both directions. The key is to use a middleware application as the central coordinator — never connect WooCommerce directly to SAP B1. The middleware owns the connection credentials for both systems, handles errors gracefully, and provides a single place to monitor and debug data flow.

Step 2: Setting Up WooCommerce Webhooks

WooCommerce webhooks are HTTP POST requests that WooCommerce sends to your middleware whenever something happens — a new order is placed, an order status changes, a product is updated, etc.

For a typical SAP B1 integration, you need to subscribe to the following WooCommerce webhook topics:

  • order.created — A new order was placed. Trigger Sales Order creation in SAP B1.
  • order.updated — An order was updated (e.g., status changed to cancelled). May need to cancel the SAP B1 Sales Order.
  • customer.created — A new customer registered. Optionally create a Business Partner in SAP B1.
Pro Tip

Always validate the webhook secret header in your middleware before processing any payload. WooCommerce signs each webhook with an HMAC-SHA256 signature using your webhook secret. Failing to validate this opens your middleware to spoofed requests.

Step 3: Order Synchronization Flow

This is the core of the integration. When a WooCommerce order webhook fires, your middleware must:

  1. Parse the WooCommerce order payload — extract line items, customer details, shipping address, payment method, and order total.
  2. Resolve or create the Business Partner in SAP B1 — search for an existing Business Partner by customer email. If found, use their CardCode. If not, create a new Business Partner record.
  3. Map WooCommerce product SKUs to SAP B1 Item Codes — this requires a mapping table or a convention where WooCommerce SKUs match SAP B1 Item Codes exactly.
  4. Check item availability — optionally query the Service Layer to verify stock before creating the order.
  5. POST the Sales Order to SAP B1 Service Layer — including all line items, quantities, prices, and the customer's CardCode.
  6. Store the SAP B1 DocEntry against the WooCommerce Order ID — this cross-reference is critical for future updates (cancellations, modifications).
  7. Update the WooCommerce order meta — write the SAP B1 DocEntry back to WooCommerce as order metadata for reference.

Need This Integration Built for Your Business?

Our team has built WooCommerce ↔ SAP B1 integrations for clients in retail, wholesale, and manufacturing. Book a free scoping call.

Request a Free 30-Minute Business Operations Review

Step 4: Inventory Sync (SAP B1 → WooCommerce)

Keeping WooCommerce product stock levels accurate requires a scheduled job that runs on your middleware — typically every 15–60 minutes, depending on your order volume and stock sensitivity.

The inventory sync job should:

  1. Query SAP B1 Service Layer for item quantities: GET /b1s/v1/Items?$select=ItemCode,OnHand,IsCommited,OnOrder
  2. Calculate available quantity: OnHand - IsCommited (items committed to open sales orders)
  3. For each item, find the matching WooCommerce product by SKU using the WooCommerce REST API
  4. Update the WooCommerce product's stock quantity using PUT /wp-json/wc/v3/products/{id}

Step 5: Error Handling & Resilience

Production integrations fail for reasons outside your control: network timeouts, SAP B1 server maintenance, WooCommerce API rate limits, or malformed payloads. Your middleware must handle all of these gracefully.

  • Retry with exponential backoff: If an API call fails with a transient error (5xx, timeout), retry after 5 seconds, then 15 seconds, then 60 seconds before giving up and alerting.
  • Dead letter queue: Failed events that exhaust retries should be stored in a "dead letter" table for manual review and replay.
  • Idempotency keys: Before creating a SAP B1 Sales Order, check your cross-reference table to ensure you haven't already processed this WooCommerce Order ID. This prevents duplicate orders when webhooks fire multiple times.
  • Alerting: Configure email or Slack alerts for critical failures (e.g., a new order could not be synced to SAP B1 after all retries).
  • Audit log: Log every processed event with its payload, outcome, and any error messages. This is essential for debugging production issues.

Step 6: Testing Your Integration

Before going live, test the following scenarios end-to-end in a staging environment:

  • New order from a brand-new customer (requires Business Partner creation)
  • New order from a returning customer (requires Business Partner lookup)
  • Order with multiple line items, including items with variable quantities
  • Order cancellation in WooCommerce — verify the SAP B1 Sales Order is cancelled or a credit note is created
  • Order with a WooCommerce product that has no matching SAP B1 Item Code — verify the error is handled gracefully and alerted
  • SAP B1 server down — verify that orders are queued and processed when the server recovers