add order status lookup for customers
All checks were successful
deploy / deploy (push) Successful in 1m17s

Magic link flow on contact page: customer enters email, gets a
time-limited signed link, clicks through to /orders showing all their
paid orders and full detail pages with thumbnails and product links.

- OrderLookupController generates/verifies Phoenix.Token signed links
- Contact LiveView handles lookup_orders + reset_tracking events
- Orders and OrderDetail LiveViews gated by session email
- Order detail shows thumbnails, links to products still available
- .themed-button gets base padding/font-weight so all usages are consistent
- order-summary-card sticky scoped to .cart-grid (was leaking to orders list)
- 27 new tests (1095 total)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-24 08:40:08 +00:00
parent 4e36b654d3
commit 01ff8decd5
19 changed files with 1030 additions and 8 deletions

View File

@@ -287,6 +287,22 @@ defmodule Berrypod.Orders do
|> Repo.all()
end
@doc """
Lists paid orders for a given customer email, newest first, with items preloaded.
Only returns paid orders — pending/failed orders aren't useful to show customers.
"""
def list_orders_by_email(email) when is_binary(email) do
normalised = String.downcase(String.trim(email))
Order
|> where([o], fragment("lower(trim(?))", o.customer_email) == ^normalised)
|> where([o], o.payment_status == "paid")
|> order_by([o], desc: o.inserted_at)
|> preload(:items)
|> Repo.all()
end
@doc """
Gets an order by its order number.
"""

View File

@@ -42,6 +42,31 @@ defmodule Berrypod.Orders.OrderNotifier do
deliver(order.customer_email, subject, body)
end
@doc """
Sends a magic link for the customer to view their orders.
The link is time-limited (controlled by the caller's token expiry).
"""
def deliver_order_lookup(email, link) do
subject = "Your order lookup link"
body = """
==============================
Here's your link to view your orders:
#{link}
This link expires in 1 hour.
If you didn't request this, you can ignore this email.
==============================
"""
deliver(email, subject, body)
end
@doc """
Sends a shipping notification with tracking info.