rename project from SimpleshopTheme to Berrypod

All modules, configs, paths, and references updated.
836 tests pass, zero warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-18 21:23:15 +00:00
parent c65e777832
commit 9528700862
300 changed files with 23932 additions and 1349 deletions

View File

@@ -24,7 +24,7 @@ Fetch shipping rates from Printify during product sync, cache them in DB, displa
## 1. Migration + schema: `shipping_rates`
**New file:** `lib/simpleshop_theme/shipping/shipping_rate.ex`
**New file:** `lib/berrypod/shipping/shipping_rate.ex`
```
shipping_rates table:
@@ -53,7 +53,7 @@ Update `Order` changeset to cast `:shipping_cost`. Update `total` calculation: `
## 3. Provider behaviour: add `fetch_shipping_rates/2`
**File:** `lib/simpleshop_theme/providers/provider.ex`
**File:** `lib/berrypod/providers/provider.ex`
```elixir
@callback fetch_shipping_rates(ProviderConnection.t(), products :: [map()]) ::
@@ -66,7 +66,7 @@ Use `@optional_callbacks [fetch_shipping_rates: 2]` — the sync worker checks `
## 4. Printify implementation
**File:** `lib/simpleshop_theme/providers/printify.ex`
**File:** `lib/berrypod/providers/printify.ex`
New function `fetch_shipping_rates/2`:
@@ -90,7 +90,7 @@ New function `fetch_shipping_rates/2`:
## 5. Shipping context
**New file:** `lib/simpleshop_theme/shipping.ex`
**New file:** `lib/berrypod/shipping.ex`
Functions:
- `upsert_rates(provider_connection_id, rates)` — bulk upsert via `Repo.insert_all` with `on_conflict: :replace`
@@ -108,7 +108,7 @@ Functions:
## 6. Wire shipping into ProductSyncWorker
**File:** `lib/simpleshop_theme/sync/product_sync_worker.ex`
**File:** `lib/berrypod/sync/product_sync_worker.ex`
In `do_sync_products/1`, after `sync_all_products(conn, products)` and before `update_sync_status(conn, "completed", ...)` (line 99), add:
@@ -120,7 +120,7 @@ Private function wraps `provider.fetch_shipping_rates(conn, products)` → `Ship
## 7. Scheduled sync worker
**New file:** `lib/simpleshop_theme/sync/scheduled_sync_worker.ex`
**New file:** `lib/berrypod/sync/scheduled_sync_worker.ex`
```elixir
use Oban.Worker, queue: :sync, max_attempts: 1
@@ -130,14 +130,14 @@ Calls `Products.list_provider_connections()`, filters enabled, enqueues `Product
**Oban cron config** (`config/config.exs`):
```elixir
{"0 */6 * * *", SimpleshopTheme.Sync.ScheduledSyncWorker}
{"0 */6 * * *", Berrypod.Sync.ScheduledSyncWorker}
```
Every 6 hours. `:sync` queue concurrency 1 serialises with manual syncs.
## 8. Checkout: Stripe shipping_options
**File:** `lib/simpleshop_theme_web/controllers/checkout_controller.ex`
**File:** `lib/berrypod_web/controllers/checkout_controller.ex`
Calculate shipping for GB (domestic) and US (international representative). Build `shipping_options` with inline `shipping_rate_data`:
@@ -156,13 +156,13 @@ shipping_options: [
If no rates found, omit `shipping_options` (current behaviour preserved).
**File:** `lib/simpleshop_theme_web/controllers/stripe_webhook_controller.ex`
**File:** `lib/berrypod_web/controllers/stripe_webhook_controller.ex`
On `checkout.session.completed`, extract `session.shipping_cost.amount_total` and update order's `shipping_cost` and `total`.
## 9. Country detection plug
**New file:** `lib/simpleshop_theme_web/plugs/country_detect.ex`
**New file:** `lib/berrypod_web/plugs/country_detect.ex`
Simple plug that runs on the `:browser` pipeline:
1. Check session for existing `country_code` — if present, skip
@@ -174,11 +174,11 @@ LiveViews read it from the session in `mount/3` via `get_session(session, "count
## 10. Cart display
**File:** `lib/simpleshop_theme_web/live/shop/cart.ex`
**File:** `lib/berrypod_web/live/shop/cart.ex`
Read `country_code` from session (default `"GB"`). Add `shipping_estimate` assign on mount using `Shipping.calculate_for_cart(cart_items, country_code)`.
**File:** `lib/simpleshop_theme_web/components/shop_components/cart.ex`
**File:** `lib/berrypod_web/components/shop_components/cart.ex`
Update `order_summary` component — add `attr :shipping_estimate, :integer, default: nil`:
- Non-nil → show `"From #{format_price(shipping_estimate)}"` + total includes estimate
@@ -194,23 +194,23 @@ Cart drawer unchanged (compact view, no shipping detail).
|------|--------|
| `priv/repo/migrations/..._create_shipping_rates.exs` | New migration |
| `priv/repo/migrations/..._add_shipping_cost_to_orders.exs` | New migration |
| `lib/simpleshop_theme/shipping/shipping_rate.ex` | New schema |
| `lib/simpleshop_theme/shipping.ex` | New context |
| `lib/simpleshop_theme/providers/provider.ex` | Add optional callback |
| `lib/simpleshop_theme/providers/printify.ex` | Implement `fetch_shipping_rates/2` |
| `lib/simpleshop_theme/sync/product_sync_worker.ex` | Wire shipping into sync |
| `lib/simpleshop_theme/sync/scheduled_sync_worker.ex` | New Oban cron worker |
| `lib/berrypod/shipping/shipping_rate.ex` | New schema |
| `lib/berrypod/shipping.ex` | New context |
| `lib/berrypod/providers/provider.ex` | Add optional callback |
| `lib/berrypod/providers/printify.ex` | Implement `fetch_shipping_rates/2` |
| `lib/berrypod/sync/product_sync_worker.ex` | Wire shipping into sync |
| `lib/berrypod/sync/scheduled_sync_worker.ex` | New Oban cron worker |
| `config/config.exs` | Add ScheduledSyncWorker to crontab |
| `lib/simpleshop_theme/orders/order.ex` | Add `shipping_cost` field |
| `lib/simpleshop_theme/orders.ex` | Cast shipping_cost, update total logic |
| `lib/simpleshop_theme/products.ex` | Add `get_variants_with_products/1` |
| `lib/simpleshop_theme_web/controllers/checkout_controller.ex` | Stripe shipping_options |
| `lib/simpleshop_theme_web/controllers/stripe_webhook_controller.ex` | Extract shipping from Stripe |
| `lib/simpleshop_theme_web/plugs/country_detect.ex` | New plug: country from Accept-Language |
| `lib/simpleshop_theme_web/router.ex` | Add CountryDetect to `:browser` pipeline |
| `lib/simpleshop_theme_web/live/shop/cart.ex` | Shipping estimate assign + country from session |
| `lib/simpleshop_theme_web/components/shop_components/cart.ex` | Display estimate |
| `lib/simpleshop_theme_web/components/page_templates/cart.html.heex` | Pass shipping_estimate |
| `lib/berrypod/orders/order.ex` | Add `shipping_cost` field |
| `lib/berrypod/orders.ex` | Cast shipping_cost, update total logic |
| `lib/berrypod/products.ex` | Add `get_variants_with_products/1` |
| `lib/berrypod_web/controllers/checkout_controller.ex` | Stripe shipping_options |
| `lib/berrypod_web/controllers/stripe_webhook_controller.ex` | Extract shipping from Stripe |
| `lib/berrypod_web/plugs/country_detect.ex` | New plug: country from Accept-Language |
| `lib/berrypod_web/router.ex` | Add CountryDetect to `:browser` pipeline |
| `lib/berrypod_web/live/shop/cart.ex` | Shipping estimate assign + country from session |
| `lib/berrypod_web/components/shop_components/cart.ex` | Display estimate |
| `lib/berrypod_web/components/page_templates/cart.html.heex` | Pass shipping_estimate |
**New files:** 5 (schema, context, worker, plug, 2 migrations)
**Modified files:** 14