Real-Time Inventory & Pricing API
Custom REST API for Real-Time Pricing & Inventory from ERP
Skills applied to this project
Built custom WooCommerce REST API endpoints that fetch live pricing and inventory from a wholesale ERP — enabling real-time product data on the storefront without cron-based sync delays.
What was the problem?
A wholesale distributor's WooCommerce B2B store had prices and stock levels that changed constantly — sometimes multiple times per day based on supplier costs and warehouse counts. A daily sync wasn't sufficient; customers were adding out-of-stock items to cart or getting prices that had changed by the time they checked out, eroding trust with their B2B buyers.
How I solved it
I built a custom REST API layer in WordPress that proxies pricing and inventory requests to the ERP's internal API. On the WooCommerce storefront, I replaced the static price display and stock status with AJAX calls to these new endpoints. Prices and inventory update live in the browser before checkout. Responses are cached in transients with a 5-minute TTL to avoid hammering the ERP while still showing near-real-time data.
Measurable results
Customers now see accurate prices and stock levels at all times. Cart abandonment due to price surprises at checkout dropped significantly. B2B buyer trust and order completion rate improved. Order error rates fell after removing stale pricing from the checkout flow.
- Price discrepancy at checkout reduced to near zero
- Out-of-stock cart additions eliminated
- B2B buyer trust and order completion rate improved
- 5-minute price cache balances accuracy and ERP API load
- No manual pricing intervention needed during supply cost fluctuations
Technical highlights
- Custom WP REST API endpoints via register_rest_route()
- ERP API proxy with authentication header management and error handling
- Transient caching with 5-minute TTL per SKU
- Front-end AJAX price injection replacing static WooCommerce output
- Fallback to WooCommerce stored price on ERP API timeout
- Role-based pricing: different price tiers per WooCommerce customer group
My process applied to this project
-
Diagnose
Understand the real business problem, user flow, and technical constraints before touching code.
-
Plan
Choose the cleanest technical approach, identify dependencies, and define what success looks like.
-
Build
Create custom WordPress/PHP solutions, plugins, integrations, or automations using best practices.
-
Test
Validate edge cases, staging behavior, logs, checkout flows, order statuses, and user roles.
-
Deploy
Release carefully with rollback awareness, staging verification, and clear documentation.
-
Improve
Monitor, optimize, and refine based on real usage, client feedback, and production behavior.
Tech used in this project
How AI accelerated this work
AI tools helped me review error logs, trace query patterns, and generate diagnostic hypotheses in minutes rather than hours — so I could focus on fixing, not searching.
I used AI to audit integration logic, catch silent failure paths, and validate that custom hooks would hold up under different WooCommerce states before going live.
AI-assisted documentation made the final plugin handoff clear and actionable for the client's internal team — reducing support questions after delivery.
Have a similar challenge?
I help e-commerce teams solve the technical problems that cost them time and revenue. Let's talk about yours.