← Back to portfolio
WordPress·2 weeks

Automated Seed Order Fulfillment System for WooCommerce

Custom WooCommerce plugin that auto-detects domestic seed orders, purchases USPS shipping labels, and emails the distributor — replacing a fully manual workflow.

WooCommercePHPUSPSShipping AutomationREST APIAction SchedulerWooCommerce ShippingLabel GenerationEmail Automation
fully hands-free fulfillment
Key Result
Umami LA — US-based e-commerce store selling seeds and merchandise through WooCommerce
Client

The Problem

The client operated a WooCommerce store selling two product types: seeds and merchandise. Merch orders were already automated through Printful, but every domestic seed order required manual intervention — checking the shipping country, verifying product categories, navigating to WooCommerce Shipping to create a label, downloading the PDF, composing an email to the distributor with order details, and attaching the label. At 10+ minutes per order and growing volume, this workflow was unsustainable and error-prone.

The Approach

Rather than building a heavy external system, I built a lightweight WordPress plugin that hooks directly into WooCommerce's order lifecycle. The plugin listens for orders entering "Processing" status, applies filtering logic (US shipping + all items in a seed category), and triggers the fulfillment pipeline. The key challenge was label generation — WooCommerce Shipping has no public API for programmatic label purchases. I reverse-engineered the plugin's internal REST endpoints and JavaScript frontend to understand the exact request format the Automattic servers expect, then replicated it server-side. A deferred email system using Action Scheduler handles the 3-minute async label generation delay, ensuring the distributor receives a single complete email with order details, tracking number, and printable 4×6 label PDF attached.

Technical Decisions

Internal REST API over external shipping APIs: WooCommerce Shipping routes all requests through Automattic's servers via Jetpack authentication. Instead of integrating a separate carrier API (which would require a new account, billing, and maintenance), I leveraged the existing WC Shipping infrastructure the client was already paying for — reducing complexity and cost. Action Scheduler for deferred processing: USPS label generation is asynchronous (~3 minutes). Rather than blocking PHP execution with sleep loops or sending incomplete emails, I used WordPress Action Scheduler to poll for label readiness and send the email only when the PDF is available. If the label isn't ready, it retries automatically every 2 minutes. Reverse-engineering over guesswork: The WC Shipping purchase endpoint rejected multiple payload formats. Instead of trial-and-error, I added a filter hook to intercept the exact API body sent by the plugin's own UI during a manual purchase, then matched our programmatic request to that format — resolving the issue immediately. Mock and dry-run modes: Built-in SOA_MOCK_MODE and SOA_DRY_RUN constants allow testing the full pipeline on staging without purchasing real labels or spending money — critical for safe iterative development on a live store. Admin user context switching: WC Shipping requires manage_woocommerce permissions. Since the plugin triggers on customer checkout (guest users), I implemented temporary admin context switching wrapped in try/finally to guarantee restoration even on errors. Graceful degradation: If any step fails (rate fetch, purchase, PDF download, email), the order stays in Processing with a detailed order note explaining what happened. Nothing is silently lost — the store owner can always handle it manually.

The Result

Umami LA's seed fulfillment workflow went from fully manual to fully autonomous. The custom plugin now intercepts every domestic seed order the moment it hits "Processing," purchases a USPS shipping label through the existing WooCommerce Shipping infrastructure, and delivers a complete fulfillment package to the distributor — all without human intervention.

Need something similar?

Let's discuss your project — I'll tell you what's realistic and how long it'll take.

Get in Touch

More Case Studies

87% faster

AI-Powered Document Processing Pipeline

Read case study →
50k txn/day

E-Commerce Backend & API Architecture

Read case study →
120h saved/mo

Business Process Automation Suite

Read case study →