# Shopify

## Article

### Metrics

- **Revenue:** $12.5K
- **Orders:** 156
- **Growth:** +24%
- **Conv. Rate:** 3.2%
- **Avg. Order:** $80
- **Visitors:** 2.4K
- **Rating:** 4.8★

### Weekly Sales

+18%  
M  
T  
W  
T  
F  
S  
S

### Monthly Trend

+32% vs last month

---  
> **Note:** Client names and some details have been changed to protect confidentiality. The technical challenges and solutions are real.

After implementing multi-location inventory for retailers with 3-10 locations, I've learned one thing: the complexity isn't in the technology — it's in the business rules.

## Solution Comparison

| Your Situation                      | Best Solution       | Cost        | Reliability |  
| ----------------------------------- | ------------------- | ----------- | ----------- |  
| 2 locations, Shopify only           | Native Shopify      | $0         | High        |  
| 2-3 locations, simple POS          | Native + app        | $50-200/mo | Medium      |  
| 3-5 locations, complex rules       | Custom middleware   | $25-50K    | Very high   |  
| 5+ locations, omnichannel          | Custom + OMS        | $50K+      | Very high   |

## The Real Challenges

### 1. Race Conditions

Customer buys last item online while another customer checks out in-store with the same item.

- **With apps:** Both sales complete. One customer gets refund email 15 minutes later.
- **With custom middleware:** Database transaction locks inventory. Second sale fails at checkout with "just sold out."

### 2. Location Priority Logic

```php
class LocationPriorityService
{
    public function getFulfillmentLocation(Order $order): Location
    {
        $available = $this->getLocationsWithStock($order);

// VIP customers get closest location
        if ($order->customer->tier === 'vip') {
            return $this->getClosestLocation($order->shippingAddress, $available);
        }

// Default: lowest shipping cost
        return $this->getCheapestShippingLocation($order, $available);
    }
}
```

Apps can't implement this. It's your business logic.

### 3. Channel-Specific Availability

Different channels see different inventory:

- **Online store:** 80% of warehouse
- **Retail stores:** Their allocated stock only
- **Wholesale:** Reserved pool only

This isn't configuration — it's code.

## When Apps Fail

**Black Friday Disaster:** Fashion retailer, 4 locations, premium inventory app ($299/month). Traffic spiked 4x. Sync lagged 30+ minutes. 340 units oversold. Cost: $47,000.

**Root cause:** App hit Shopify API rate limits. Queue backed up.

## The Architecture That Works

```
Sales Channels (Shopify, Lightspeed A, Lightspeed B)
                    ↓ Webhooks
        Inventory Middleware (Laravel)
    [Ledger] [Allocation Rules] [Routing Logic]
                    ↓
            All Inventory Systems
```

**Key principles:**

1. Single source of truth — middleware database
2. Atomic transactions — database locks prevent races
3. Business rules in code — not app configuration
4. Audit everything — full history for reconciliation

## The Cost Math

At 100 orders/day across 3 locations with $200 average order:

- 1% overselling rate = $600/day = $18,000/month
- Custom middleware: $35K + $1K/month

**Custom pays for itself in under 2 months of prevented overselling.**

## Getting Started

**Under 50 orders/day with 2 locations:** Start with native Shopify.

**50-200 orders/day with 3+ locations:** Evaluate custom middleware now.

**Already been burned:** Stop patching apps. Build properly.

## Need Multi-Location Inventory Help?

We can help you figure out the right architecture for your specific operation.

### Written by

#### Eyal Gantz

Founder & Lead Developer

Expert in e-commerce development and business automation with 10+ years of experience building custom technology solutions.

### Tags

- [inventory management](https://teamwil.co/blog/tag/inventory%20management)  
- [multi-location](https://teamwil.co/blog/tag/multi-location)  
- [shopify](https://teamwil.co/blog/tag/shopify)
