Add real order persistence, customer accounts, and cart sync

Checkout now persists orders server-side (Payload orders collection,
re-priced from live product data, discount codes redeemed exactly once)
instead of writing a client-only sessionStorage snapshot. Buying requires
an account (registration inline in checkout, no separate step) — accounts
get order history with delivery status, profile/address editing, password
change, and a cart that syncs across devices while logged in.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Marco
2026-07-22 06:45:42 +00:00
parent 516945fc8c
commit 7f37f111e8
27 changed files with 1697 additions and 89 deletions
+8 -1
View File
@@ -3,6 +3,7 @@ import { CheckoutContent } from "./components/CheckoutContent";
import { TrustRow } from "../components/TrustRow";
import { Footer } from "../components/Footer";
import { getShippingMethods, getPaymentMethods, getCartTrustBadges, getShippingSettings } from "../lib/payload";
import { getSessionCustomer, getCustomerProfile } from "../lib/customerAuth";
// robots: noindex — transactional page, same reasoning as /cart.
export const metadata: Metadata = {
@@ -15,12 +16,16 @@ export const metadata: Metadata = {
};
export default async function CheckoutPage() {
const [shippingMethods, paymentMethods, trustBadges, shippingSettings] = await Promise.all([
const [shippingMethods, paymentMethods, trustBadges, shippingSettings, session] = await Promise.all([
getShippingMethods(),
getPaymentMethods(),
getCartTrustBadges(),
getShippingSettings(),
getSessionCustomer(),
]);
// Full profile (incl. saved address) only fetched when a session exists
// — pre-fills Card 1 for a returning customer instead of leaving it blank.
const profile = session ? await getCustomerProfile(session.token) : null;
return (
<>
@@ -30,6 +35,8 @@ export default async function CheckoutPage() {
paymentMethods={paymentMethods}
trustBadges={trustBadges}
shippingSettings={shippingSettings}
customerEmail={session?.customer.email ?? null}
savedProfile={profile}
/>
<TrustRow />
</main>