A micro-service to integrate and synchronize products between a local database or SOAP sources and WooCommerce stores.
- List products for a client from:
-
- Local database (via stored procedure
obtener_datos_productos)
- Local database (via stored procedure
-
- SOAP web service (via Zeep client)
- Retrieve WooCommerce inventory
- SOAP warehouse items endpoint
- Background synchronization (stock, images) with WooCommerce
- "Personal" synchronization based on changed-products table
- Compare local vs remote inventories
- Identify and create missing products in WooCommerce
- Update price lists from SOAP sources
- Batch operations script with WhatsApp notifications (via Twilio)
- Python 3.11+
- PostgreSQL (or another DB supported by async SQLAlchemy)
- WooCommerce store(s) with REST API enabled
- (Optional) Twilio account for WhatsApp notifications
-
Clone the repository:
git clone https://github.com/tonysl3003/sysMIWE.git cd wooIntegration -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile based on the following example and fill in your credentials:# Database URL (asyncpg) DATABASE_URL=postgresql+asyncpg://user:password@host:port/dbname # API clients (WooCommerce stores) CLIENTS_API_JSON='[ {"client":"client1","url":"https://store.example.com","ck":"ck_xxx","cs":"cs_xxx","dbId":1,"provider":"db"} ]' # SOAP clients (warehouse bodega) SOAP_CREDENTIALS_JSON='[ {"client":"client1","siretUrl":"example.com","ws_pid":12345,"ws_passwd":"pwd","bid":0} ]' # Twilio WhatsApp (optional) TWILIO_ACCOUNT_SID=your_account_sid TWILIO_AUTH_TOKEN=your_auth_token TWILIO_FROM_WHATSAPP=whatsapp:+14155238886 TWILIO_TO_WHATSAPP=whatsapp:+1234567890 # Base URL for batch sync script (defaults to http://localhost:8000) API_BASE_URL=http://localhost:8000
uvicorn main:app --reload --host 0.0.0.0 --port 8000 --root-path="/api"The API will be available at http://localhost:8000/api.
GET /api/— Hello worldGET /api/health— Health check ({"status":"ok"})GET /api/items/{client}— List products for a client (DB or SOAP)GET /api/inventory/{client}— List all WooCommerce products for a clientGET /api/soap/{client}/bodega_items— SOAP warehouse items for a clientPOST /api/sync/{client}— Start background synchronizationPOST /api/syncPersonal/{client}— Run personal synchronization and return summaryPOST /api/clearProdsChange— Truncate theprodsChangestableGET /api/compare/{client}— Start background comparison of inventoriesGET /api/missingwp/{client}— List SKUs present locally but missing in WooCommercePOST /api/missingwp/{client}/create— Start background creation of missing WooCommerce productsPOST /api/updatePriceList— Update price lists from predefined SOAP configs
Visit http://localhost:8000/api/docs for interactive Swagger UI.
A helper script sync_all.py runs:
- SOAP store operations for all SOAP clients
syncPersonalfor all API clients- Clears the
prodsChangestable - Sends a WhatsApp summary via Twilio
Run it with:
python sync_all.pyFeel free to submit issues or pull requests. Please follow the project's coding style and add tests for new features.
MIT