TCPOS Product Sync
Modular product synchronization scaffold for TCPOS and WooCommerce.
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/drizy/tcpos-wordpress/archive/refs/heads/main.zipReadme
TCPOS Product Sync
Synchronizes TCPOS products into WooCommerce and pushes WooCommerce orders back to TCPOS.
This plugin aims to keep products in sync from TCPOS to WooCommerce and to notify TCPOS about orders and payment status updates from your store.
Features
- Admin dashboard page: TCPOs Sync
- Settings stored in
wp_options - Manual sync actions (Test Connection / Run Full Sync / Sync Updates)
- AJAX settings form save (no page reload)
- AJAX admin notices for save/sync/test actions
- Automatic product sync via WP-Cron (
tcpos_sync_products_event, every 5 minutes) - Product upsert by
_tcpos_idwith category auto-create and stock management - Immediate outbound order sync when an order is created via checkout (hook:
woocommerce_checkout_order_created) - Non-blocking frontend AJAX hook that attempts to sync when the customer completes checkout (sends order_id to admin AJAX endpoint)
- Separate order-status-update endpoint to report payment status/type/amount
- Option to send a dummy paid amount (random value <= order total) for testing/privacy
- Skips sending payment updates for unsupported payment methods (cash/COD, cheque) or when no payment method is available
- Duplicate guard using order meta
_tcpos_syncedto avoid re-creating the same order in TCPOS - Logging to
logs/plugin.log+ recent logs inwp_options - API retry behavior for transient failures (timeouts, 5xx, 429)
Key Paths
tcpos-product-sync.php- plugin bootstrapapi/ApiClient.php- API client + retry + pagination helperssync/ProductSyncService.php- product import/update servicesync/OrderSyncService.php- completed order sync servicesync/class-sync-manager.php- cron hooks + orchestrationadmin/class-admin.php- settings, UI, AJAX handlerslogs/class-logger.php- file/option logging utilities
New / changed files of interest:
admin/js/tcpos-checkout.js- frontend JS that attempts a non-blocking AJAX POST to the plugin when checkout completesapi/ApiClient.php- addedupdateOrderPaymentStatus()and configuration for an "order status update" endpointsync/OrderSyncService.php- includesorder_id(as string) in the creation payload and handles sending payment status updates (amount, payment_type, payment_status)admin/class-admin.php- settings UI now includesOrder Status Update EndpointandUse Dummy Paid Amountoptions
Setup
- Activate plugin in WordPress admin.
- Open TCPOs Sync menu.
- Configure:
- API Base URL
- Products Endpoint
- Orders Endpoint
- Order Status Update Endpoint (optional) — POSTs payment updates:
order_id(string),payment_status,payment_type,status,amount - API Key (optional)
- Store/Organisation ID (optional)
- Use Dummy Paid Amount (Yes/No) — if enabled the plugin will send a random amount less than or equal to the order total when reporting payment updates (useful for testing)
- Save settings.
- Use Test Connection before first full sync.
Where To Find It In Dashboard
- Left admin menu:
TCPOs Sync - WordPress Dashboard widget:
TCPOs Sync Status
The dashboard widget shows the last sync summary and a quick button to open plugin settings.
AJAX Behavior
- The settings form is submitted using AJAX and saved to
wp_options. - Sync buttons send current form values via AJAX before running actions.
- Results are shown in-page and also rendered as WordPress admin notices via AJAX.
- Only the API Base URL is required for sync operations. API Key and Store/Organisation ID are optional.
Frontend checkout behavior
- When a customer completes checkout, the plugin's frontend script (
admin/js/tcpos-checkout.js) attempts a non-blocking AJAX POST to the plugin'stcpos_product_sync_checkout_order_syncaction withorder_id. - This is best-effort and non-blocking — it will not delay checkout. The server-side handler will call the existing order sync logic (and/or payment update logic) for the provided order.
- The plugin also hooks into WooCommerce order status changes (status-created and status-changed) and will call the configured Order Status Update Endpoint when appropriate.
Sync Mapping
id->_tcpos_idattributes.name-> product titleattributes.notes-> product descriptionattributes.product_price-> WooCommerce price (_price)attributes.stock.quantityorattributes.in_stock->_stockattributes.product_category_name-> WooCommerceproduct_cat
Order Payload
When an order reaches completed, this payload is sent:
{
"order_id": "123",
"products": [{ "product_id": "abc", "quantity": 1 }],
"total": 1000,
"customer": { "name": "Jane Doe", "email": "jane@example.com" }
}
Testing
- Validation checklist:
tests/validation-checklist.md - Smoke test script:
tests/smoke-test.php
Order status update payload
When reporting a payment/status update the plugin will POST to the configured Order Status Update Endpoint with a payload similar to:
{
"order_id": "123",
"payment_status": 1,
"payment_type": 2,
"status": 2,
"amount": 25.50
}
Validation & skip rules
- The plugin will not send payment updates when the order's payment method is missing.
- The plugin will skip updates for cash/COD and cheque methods (these are not sent by default).
- The plugin validates that
payment_type,payment_statusandstatusare within supported ranges before attempting to POST. If invalid, the request will be aborted and an error logged.
Deployment
- Ensure plugin is configured and sync tested in staging.
- Remove temporary/dev-only artifacts if added during local development.
- Package plugin folder as zip.
Example packaging command:
cd /Users/idristabi/Projects/wordpress/brenssmallchops/wp-content/plugins
zip -r tcpos-product-sync.zip tcpos-product-sync
Troubleshooting Visibility
If the plugin does not appear in WordPress admin:
- Confirm folder path is
wp-content/plugins/tcpos-product-sync. - Confirm main file exists:
wp-content/plugins/tcpos-product-sync/tcpos-product-sync.php. - In Plugins, activate TCPOS Product Sync.
- Log out/in and hard refresh admin.
- Check
wp-content/plugins/tcpos-product-sync/logs/plugin.logfor startup errors.
Logging and debugging
- The plugin logs important steps to
wp-content/plugins/tcpos-product-sync/logs/plugin.logand stores recent log entries in an option for quick retrieval in the admin UI. - Archived log files are compressed to
.log.gzand kept for 7 days before removal. - Recent log entries stored in the database are also pruned on the same 7-day window.
- If you enable the Order Status Update Endpoint, you can temporarily point it at a request inspector (e.g., https://webhook.site/) to confirm payload shape and field contents.
Notes
order_idis always sent as a string to both the orders endpoint and the order-status-update endpoint.- The frontend AJAX attempt is best-effort; the server-side hooks also run on order creation and status changes to ensure updates are sent even if the client-side request does not arrive.
- If you want to ensure only real payments are reported, leave "Use Dummy Paid Amount" disabled (default). Enable it only for testing.