Full-stack e-commerce automation for a DTC leather brand in Pakistan
A fast-growing Shopify store was losing money on every COD return and spending hours on manual order tracking. We built five interconnected systems that eliminated the manual work entirely.
Cash-on-delivery is how Pakistan shops. It is also how stores lose money.
The brand was processing 50+ daily orders, nearly all COD. Three recurring problems were eating into margins and consuming hours of staff time every day.
Ghost deliveries
Couriers would attempt delivery, find no one home, and return the parcel. The store paid shipping both ways on orders that were never real. No system existed to confirm intent before dispatch.
Manual payment tracking
When a COD order was delivered, someone had to manually log into the courier portal, cross-reference the order, and mark it as paid in Shopify. For 50+ daily orders, this consumed 2-3 hours.
Zero delivery visibility
The team had no idea where orders were after handoff to the courier. Customer inquiries about delivery status required logging into a separate portal and searching manually.
Five systems, one automation layer
Each system runs independently but they share data. Together, they form a complete operations layer that handles delivery, payment, customer communication, and online visibility without manual intervention.
A Python service runs twice daily (9 AM and 6 PM local time), pulling live courier data via the courier’s API and writing the latest status directly into each Shopify order — tags, notes, and timeline events.
- Every active order is checked against the courier’s tracking system
- Statuses mapped: In Transit, Out for Delivery, Delivered, Attempted, Returned
- Full delivery history added to Shopify order notes
- Returned shipments flagged immediately for resolution
- Resolved orders are permanently skipped to avoid wasted API calls
The moment the courier confirms delivery, the system automatically records the COD payment against that order in Shopify. Revenue reflects reality in real time.
- Payment captured at the exact order amount, no rounding, no manual errors
- Only COD orders are processed. prepaid orders are never touched
- Cancelled and returned orders are protected from accidental payment
- Full audit trail: payment timestamp, courier confirmation, and order tag added simultaneously
At checkout, customers are automatically offered a 10% discount for paying via bank transfer instead of cash on delivery. No discount codes, no friction. the incentive is built directly into the checkout experience.
- 10% discount applied instantly when bank transfer is selected
- Promotional banner appears at the payment step
- COD option hidden once prepay is selected to prevent switching back
- Every prepaid order eliminates return risk entirely. cash received before anything ships
- Custom Shopify Liquid templates handle the logic without apps
Every new COD order triggers an instant WhatsApp message to the customer. They reply YES to confirm or NO to cancel. No reply within 24 hours means automatic cancellation. No courier is dispatched to a ghost customer.
- Sent within seconds of order placement via Meta WhatsApp Business API
- Bilingual message. English and Urdu in one message
- YES/NO keyword detection handles replies automatically
- Silent orders cancelled and inventory restocked after 24 hours
- Built as a Flask microservice with Supabase for state management
Your order #71502 worth PKR 4,698 has been placed.
Reply YES to confirm.
Reply NO to cancel.
A comprehensive audit uncovered why the store was invisible to both Google and AI search engines. We identified 38 issues across technical SEO, content quality, schema markup, and performance. then built a prioritized action plan and produced the first wave of B2B content to open a wholesale channel.
- Overall SEO health score: 38/100 at audit, target 82/100 after fixes
- All rich results were blocked. schema used http:// instead of https://
- Hero image lazy-loaded (LCP > 4s). fixed for immediate Core Web Vitals improvement
- Two major collection URLs returning 404. redirects created
- Created 3 B2B landing pages (wholesale, custom, corporate) and 5 SEO blog posts
- Prioritized 50+ fixes across Critical, High, Medium, and Low tiers
The order lifecycle, fully automated
From the moment a customer places an order to the moment revenue is confirmed, every step runs without human input.
Customer places COD order on Shopify
Shopify webhook fires immediately, triggering the WhatsApp confirmation system.
InstantWhatsApp message sent to customer
Bilingual confirmation request sent via Meta API. Customer replies YES or NO. No reply after 24 hours triggers automatic cancellation and inventory restock.
Within secondsConfirmed order dispatched to courier
Only confirmed orders move to fulfillment. Ghost customers are filtered out before any shipping cost is incurred.
Delivery sync runs twice daily
At 9 AM and 6 PM, the Python service queries the courier API and updates every active order in Shopify with the latest status, notes, and tags.
9 AM & 6 PMCourier confirms delivery
The sync detects the delivery confirmation and automatically marks the COD payment as captured in Shopify. Revenue is recorded instantly.
AutomaticDaily summary email sent to team
After each sync, a clean report lands in the owner’s inbox, orders delivered, payments captured, returns flagged, items still in transit.
2x dailyWhat changed after deployment
Measurable improvements across operations, revenue accuracy, and team capacity.
0 hours/day on manual tracking
The team previously spent 2–3 hours daily cross-referencing courier portals and updating Shopify. That work is now fully automated.
100% COD payment reconciliation
Every delivered COD order is automatically marked as paid at the exact amount. No orders slip through, no manual data entry errors.
Ghost orders filtered before dispatch
WhatsApp confirmation prevents shipping to customers who never intended to accept delivery. Unconfirmed orders are cancelled before courier pickup.
Real-time delivery tracking in Shopify
Every order shows its latest courier status directly in Shopify, no external portal logins required. Customer service can answer status questions in seconds.
38 → 82 SEO health score (target)
Critical fixes deployed: schema corrected to unlock rich results, hero image LCP fixed, broken collection URLs redirected, 8 pieces of B2B content published.
System scales from 50 to 5,000 orders/day
The automation layer handles the same workload whether the store processes 50 orders or 5,000. Growth no longer requires proportional headcount.
What powers it
Backend
Python · Flask · Supabase (PostgreSQL) · Heroku · APScheduler for cron jobs
Integrations
Shopify Admin API · Courier tracking API · Meta WhatsApp Business API · SMTP email
Frontend
Shopify Liquid (theme customization) · Custom checkout scripts · SEO schema (JSON-LD)
Running a similar operation?
If your product brand is losing money on COD returns, spending hours on manual order tracking, or invisible on search. we have built systems that solve exactly these problems.
Book a Free Discovery Call →