From fd355c3397fbdd9f9f83bf03d6b13838757f7217 Mon Sep 17 00:00:00 2001 From: jamey Date: Tue, 24 Feb 2026 13:19:54 +0000 Subject: [PATCH] use shop_name and email_from_address settings for all outbound emails All three notifier functions (order confirmation, shipping, cart recovery) now read from the same two settings rather than using hardcoded values or duplicating the lookup. Co-Authored-By: Claude Sonnet 4.6 --- lib/berrypod/orders/order_notifier.ex | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/lib/berrypod/orders/order_notifier.ex b/lib/berrypod/orders/order_notifier.ex index 0440bb3..877e140 100644 --- a/lib/berrypod/orders/order_notifier.ex +++ b/lib/berrypod/orders/order_notifier.ex @@ -98,8 +98,6 @@ defmodule Berrypod.Orders.OrderNotifier do Plain text, no tracking pixels, single send. Includes an unsubscribe link. """ def deliver_cart_recovery(cart, order, unsubscribe_url) do - from_address = Berrypod.Settings.get_setting("email_from_address", "contact@example.com") - subject = "You left something behind" base_url = BerrypodWeb.Endpoint.url() body = """ @@ -118,33 +116,19 @@ defmodule Berrypod.Orders.OrderNotifier do ============================== """ - email = - new() - |> to(cart.customer_email) - |> from(from_address) - |> subject(subject) - |> text_body(body) - - case Mailer.deliver(email) do - {:ok, _metadata} = result -> - result - - {:error, reason} = error -> - Logger.warning( - "Failed to send cart recovery email to #{cart.customer_email}: #{inspect(reason)}" - ) - - error - end + deliver(cart.customer_email, "You left something behind", body) end # --- Private --- defp deliver(recipient, subject, body) do + shop_name = Berrypod.Settings.get_setting("shop_name", "Berrypod") + from_address = Berrypod.Settings.get_setting("email_from_address", "contact@example.com") + email = new() |> to(recipient) - |> from({"Berrypod", "contact@example.com"}) + |> from({shop_name, from_address}) |> subject(subject) |> text_body(body)