woocommerce api
🔗 WooCommerce Webhook Integration Guide (Smarton)
This guide explains how to connect your WooCommerce store with the Smarton system for real-time product sync using webhooks.
📌 Webhook Endpoints
| Event | Endpoint URL |
|---|---|
| Product Created | https://domain.smarton.app/api/public/online_payments/create_woocommerce_article |
| Product Updated | https://domain.smarton.app/api/public/online_payments/update_woocommerce_article |
✅ Note: Replace
domain.smarton.appwith your actual Smarton domain.
🛠 How to Add Webhooks in WooCommerce
Log in to your WordPress Admin Panel.
Go to WooCommerce > Settings > Advanced > Webhooks.
Click "Add Webhook".
Fill in the following details for each event:
🔁 For Product Created
Name:
Smarton - Product CreatedStatus:
ActiveTopic:
Product createdDelivery URL:
https://domain.smarton.app/api/public/online_payments/create_woocommerce_articleSecret: (Optional, only if Smarton uses one)
API Version:
WP REST API v3Click Save Webhook
🔁 For Product Updated
Name:
Smarton - Product UpdatedStatus:
ActiveTopic:
Product updatedDelivery URL:
https://domain.smarton.app/api/public/online_payments/update_woocommerce_articleSecret: (Optional)
API Version:
WP REST API v3Click Save Webhook
🔑 How to Connect Your WooCommerce Account to Smarton
To enable Smarton to fetch product variation details via the WooCommerce API:
In the Smarton admin panel, go to
Settings > Integrations > eShopsClick "Add +" or edit an existing one.
Fill in the fields:
Name:
woocommerceType:
woocommerceDomain:
https://yourstore.com/wp-json/wc/v3(this is your WooCommerce REST API URL)Token (Consumer Key): e.g.,
ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXPassword (Consumer Secret): e.g.,
cs_YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
Click Save.
These credentials are required for the Smarton system to authenticate and fetch product variations for each incoming webhook.
📤 Data Format (Webhook POST Body Example)
WooCommerce sends product data in JSON format. Example payload:
{
"id": 1234,
"name": "Classic Coffee Mug",
"price": "14.99",
"regular_price": "19.99",
"sale_price": "14.99",
"description": "A sturdy mug for your morning coffee.",
"sku": "MUG001",
"variations": [456, 457]
}
idis used as the external identifier (stored inaltNamein Smarton).If
sale_pricediffers fromregular_price, the system automatically adds a discount label to the product name.If
variationsare included, the Smarton system will fetch and sync each variation via the WooCommerce API.SKU is limited to 32 characters.
✅ What Happens Next
On Product Created: A new product is added to your Smarton catalog.
On Product Updated: The existing product is updated. If it does not exist yet, it will be created automatically.
Variations: Synced and updated using WooCommerce API credentials provided in the Smarton
EShoprecord.
🔒 Security Notes
Ensure your server accepts POST requests from WooCommerce (check firewall, security plugins, etc.).
You may optionally configure a shared webhook secret in both WooCommerce and Smarton to validate requests.
Smarton supports signature verification upon request.
🔁 Periodic Stock Synchronization with WooCommerce
Smarton allows you to automatically synchronize stock levels from Smarton orders back to WooCommerce using periodic listeners.
This is useful when product quantities need to be deducted in WooCommerce after sales are finalized in Smarton.
🧭 How to Enable Automatic Sync (Pro version only)
⚠️ This feature is available only to users of the paid Smarton version.
Log in to your Smarton back office.
Navigate to:
Staff → Notifications → Periodic Listeners.Click the ➕ Add Listener button.
In the first screen:
Name: Choose a recognizable name, e.g.,
WooCommerce Stock Sync.Action: Select
WoocommerceSynchronizationActionfrom the dropdown.
In the second screen:
Set how frequently you want the synchronization to run (e.g., every 30 minutes).
Fill in the required WooCommerce API configuration:
consumerKey: Your WooCommerce REST API Consumer KeyconsumerSecret: Your Consumer SecretapiUrl: Your WooCommerce API base URL (e.g.https://yourstore.com)syncPeriodMinutes: How many past minutes to check for new orders (e.g.,30)
Save the listener. It will automatically run based on the interval you specified.
🔄 What This Does
Every time the listener runs, Smarton:
Finds completed orders from the past X minutes.
For each product in the order:
Finds the matching product in WooCommerce (by
altName).Deducts the sold quantity from WooCommerce’s stock.
Updates the Smarton order product with a synced quantity and clears any sync error.
Logs any synchronization error (like missing WooCommerce product).
📌 Example Configuration
| Field | Value |
|---|---|
| consumerKey | ck_XXXXXXXXXXXXXXXXXXXX |
| consumerSecret | cs_YYYYYYYYYYYYYYYYYYYY |
| apiUrl | https://yourstore.com |
| syncPeriodMinutes | 30 |
✅ Requirements
Your product in Smarton must have
altNameset to match the WooCommerce product ID.The Smarton order must be completed (
finishedAtset).You must be using the paid version of Smarton to enable periodic listeners.
Your WooCommerce product must have stock management enabled.
English