Skip to content

Commit 12b21bd

Browse files
skvostclaude
andcommitted
feat(checkout): carry prefill params from event page to details step
SelectProducts forwards first_name/last_name/email/lock from the event page URL into the order-creation navigation, so query-param prefill survives to the checkout details step (not just direct deep-links). Adds CHECKOUT_PREFILL_PARAM_KEYS as the single source of truth. 🤖 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 35ef667 commit 12b21bd

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

frontend/src/components/routes/product-widget/SelectProducts/index.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {IconChevronRight, IconX} from "@tabler/icons-react"
3737
import {getSessionIdentifier} from "../../../../utilites/sessionIdentifier.ts";
3838
import {Constants} from "../../../../constants.ts";
3939
import {clearWaitlistJoinedForEvent} from "../../../../hooks/useWaitlistJoined.ts";
40+
import {CHECKOUT_PREFILL_PARAM_KEYS} from "../../../../hooks/useCheckoutPrefill.ts";
4041

4142
const AFFILIATE_EXPIRY_DAYS = 30;
4243

@@ -150,16 +151,29 @@ const SelectProducts = (props: SelectProductsProps) => {
150151
onSuccess: (data) => queryClient.invalidateQueries()
151152
.then(() => {
152153
const url = '/checkout/' + eventId + '/' + data.data.short_id + '/details';
154+
155+
// Forward checkout-prefill params (name/email/lock) from the event page
156+
// to the details step, since this navigation would otherwise drop them.
157+
const sourceParams = new URLSearchParams(window.location.search);
158+
const prefillParams = new URLSearchParams();
159+
CHECKOUT_PREFILL_PARAM_KEYS.forEach((key) => {
160+
const value = sourceParams.get(key);
161+
if (value !== null) {
162+
prefillParams.set(key, value);
163+
}
164+
});
165+
const prefillQuery = prefillParams.toString();
166+
153167
if (props.widgetMode === 'embedded') {
154-
window.open(
155-
url + '?session_identifier=' + data.data.session_identifier + '&utm_source=embedded_widget',
156-
'_blank'
157-
);
168+
const embeddedQuery = 'session_identifier=' + data.data.session_identifier
169+
+ '&utm_source=embedded_widget'
170+
+ (prefillQuery ? '&' + prefillQuery : '');
171+
window.open(url + '?' + embeddedQuery, '_blank');
158172
setOrderInProcessOverlayVisible(true);
159173
return;
160174
}
161175

162-
return navigate(url);
176+
return navigate(url + (prefillQuery ? '?' + prefillQuery : ''));
163177
}),
164178

165179
onError: (error: any) => {

frontend/src/hooks/useCheckoutPrefill.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ export interface UseCheckoutPrefillResult {
1212
lock: boolean;
1313
}
1414

15+
// Query params the checkout details form reads to prefill itself. Also forwarded
16+
// from the event page to the details step so prefill survives order creation
17+
// (see SelectProducts).
18+
export const CHECKOUT_PREFILL_PARAM_KEYS = ["first_name", "last_name", "email", "lock"] as const;
19+
1520
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1621

1722
export const useCheckoutPrefill = (): UseCheckoutPrefillResult => {

0 commit comments

Comments
 (0)