Description
WooCommerce fires an action whenever an order is completed, its status changes, or a product is created or updated. This plugin lets you pick one of these events and define a shortcode that is executed each time the event occurs.
The shortcode receives all relevant WooCommerce data (order, line items, SKUs, or product details) as a URL-encoded JSON string via the placeholder #orderdata#. Use it to push orders or products to another shop system, an ERP, a CRM, or any REST API – for example with the PRO version of the JSON Content Importer or with a shortcode plugin of your own.
Features
- Event-based trigger – choose one WooCommerce hook per site:
- Order thank-you page (
woocommerce_thankyou) - Order completed (
woocommerce_order_status_completed) - Order status changed (
woocommerce_order_status_changed) - Product created or updated (
woocommerce_update_product)
- Order thank-you page (
- Shortcode execution – the configured shortcode runs with the event data injected via
#orderdata#. - Duplicate protection – orders are marked after a successful sync, so reloading the thank-you page does not trigger a second call.
- Multisite-aware SKU lookup – if a product is not found on the current site, the other sites of the network are checked.
- Logging – the last 20 events (event, order/product, shortcode result) are stored and shown in the admin, with links to the order or product.
- E-mail notification – optionally receive a short e-mail per event with order number, event type and shortcode result.
- HPOS-compatible – works with WooCommerce High-Performance Order Storage and the block-based Cart/Checkout.
- Clean uninstall – all settings and log data are removed on deletion if you opt in.
Privacy
The plugin only processes data on your own site. Order and product data are handed to the shortcode you configure; whether that shortcode sends data to a third party is up to the shortcode plugin you use. The built-in log stores event type, order/product ID and shortcode result – no customer names, addresses or e-mail addresses. The optional notification e-mail contains the order number and the shortcode result, not the order data itself.
Installation
- Install and activate WooCommerce.
- Install and activate this plugin.
- Install a plugin that provides the shortcode you want to run (e.g. JSON Content Importer PRO), or write your own.
- Go to API Data Sync Basic Settings, choose the WooCommerce event and enter the shortcode. Use
#orderdata#as the placeholder for the event data. - Optionally enable logging and/or enter an e-mail address for notifications.
- Place a test order or save a product and check the log.
FAQ
-
Which other plugins do I need?
-
WooCommerce, and a plugin that provides the shortcode to be executed. The JSON Content Importer PRO plugin can do this out of the box; alternatively you can write a small plugin yourself that registers a shortcode, reads the
param1attribute and calls your API. -
What data does the shortcode receive?
-
For order events: the complete order (as returned by
WC_Order::get_data()), all line items and the resolved SKU per item. For product events: ID, name, descriptions, prices, SKU, stock status, categories and tags. For status changes: order ID, old and new status. Everything is passed as one URL-encoded JSON string. -
An order was synced twice. Why?
-
Each event is only processed once per order. If you switched the trigger from “thank-you page” to “order completed”, both events can fire for the same order once. Also note that
woocommerce_order_status_changedfires on every status change, including the change to “completed”. -
Does the plugin work with HPOS?
-
Yes. Compatibility with High-Performance Order Storage and Cart/Checkout Blocks is declared, and all order access goes through the WooCommerce CRUD API.
-
Where can I get help?
-
Open a topic in the plugin’s support forum on WordPress.org.
Reviews
There are no reviews for this plugin.
Contributors & Developers
“API Data Sync for WooCommerce” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “API Data Sync for WooCommerce” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
1.0
- Declared compatibility with WooCommerce High-Performance Order Storage (HPOS) and Cart/Checkout Blocks
- Orders are now marked after sync to prevent duplicate calls on thank-you page reloads
- Log and notification e-mails no longer contain customer data; log entries link to the order or product
- Log option is no longer autoloaded
- Admin capability changed from role name to
manage_woocommerce - Simplified nonce handling on the settings page
- Multisite SKU lookup checks the current site first and stops at the first match
- Tested with WordPress 7.1, WooCommerce 11.1 and Plugin Check 2.1.0
0.7
- Tested with WordPress 7.0 and Plugin Check 1.9.0
0.3
- Initial version
