Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/green-monkeys-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@godaddy/react": patch
"@godaddy/localizations": patch
---

Add additional targets and extend billing flows with localization updates
4 changes: 4 additions & 0 deletions packages/localizations/src/deDe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const deDe = {
payment: {
title: 'Zahlung',
description: 'Alle Zahlungen sind sicher und verschlüsselt.',
billingInformation: {
title: 'Rechnungsinformationen',
description: 'Geben Sie Ihre Rechnungsinformationen ein.',
},
billingAddress: {
title: 'Rechnungsadresse',
description: 'Geben Sie Ihre Rechnungsadresse ein.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/enAu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const enAu = {
payment: {
title: 'Payment',
description: 'All payments are secure and encrypted.',
billingInformation: {
title: 'Billing Information',
description: 'Enter your billing information.',
},
billingAddress: {
title: 'Billing Address',
description: 'Enter your billing address.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/enIe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const enIe = {
payment: {
title: 'Payment',
description: 'All payments are secure and encrypted.',
billingInformation: {
title: 'Billing Information',
description: 'Enter your billing information.',
},
billingAddress: {
title: 'Billing Address',
description: 'Enter your billing address.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/enUs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const enUs = {
payment: {
title: 'Payment',
description: 'All payments are secure and encrypted.',
billingInformation: {
title: 'Billing Information',
description: 'Enter your billing information.',
},
billingAddress: {
title: 'Billing Address',
description: 'Enter your billing address.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/esAr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const esAr = {
payment: {
title: 'Pago',
description: 'Todos los pagos son seguros y encriptados.',
billingInformation: {
title: 'Información de facturación',
description: 'Ingrese su información de facturación.',
},
billingAddress: {
title: 'Dirección de Facturación',
description: 'Ingresá tu dirección de facturación.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/esCl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const esCl = {
payment: {
title: 'Pago',
description: 'Todos los pagos son seguros y encriptados.',
billingInformation: {
title: 'Información de facturación',
description: 'Ingrese su información de facturación.',
},
billingAddress: {
title: 'Dirección de Facturación',
description: 'Ingresa tu dirección de facturación.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/esCo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const esCo = {
payment: {
title: 'Pago',
description: 'Todos los pagos son seguros y encriptados.',
billingInformation: {
title: 'Información de facturación',
description: 'Ingrese su información de facturación.',
},
billingAddress: {
title: 'Dirección de facturación',
description: 'Ingresa tu dirección de facturación.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/esEs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const esEs = {
payment: {
title: 'Pago',
description: 'Todos los pagos son seguros y están encriptados.',
billingInformation: {
title: 'Información de facturación',
description: 'Introduce tu información de facturación.',
},
billingAddress: {
title: 'Dirección de facturación',
description: 'Introduce tu dirección de facturación.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/esMx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const esMx = {
payment: {
title: 'Pago',
description: 'Todos los pagos son seguros y cifrados.',
billingInformation: {
title: 'Información de facturación',
description: 'Ingrese su información de facturación.',
},
billingAddress: {
title: 'Dirección de Facturación',
description: 'Ingrese su dirección de facturación.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/esPe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const esPe = {
payment: {
title: 'Pago',
description: 'Todos los pagos son seguros y encriptados.',
billingInformation: {
title: 'Información de facturación',
description: 'Ingrese su información de facturación.',
},
billingAddress: {
title: 'Dirección de Facturación',
description: 'Ingrese su dirección de facturación.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/esUs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const esUs = {
payment: {
title: 'Pago',
description: 'Todos los pagos son seguros y encriptados.',
billingInformation: {
title: 'Información de facturación',
description: 'Ingrese su información de facturación.',
},
billingAddress: {
title: 'Dirección de Facturación',
description: 'Ingrese su dirección de facturación.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/frCa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const frCa = {
payment: {
title: 'Paiement',
description: 'Tous les paiements sont sécurisés et chiffrés.',
billingInformation: {
title: 'Informations de facturation',
description: 'Saisissez vos informations de facturation.',
},
billingAddress: {
title: 'Adresse de facturation',
description: 'Entrez votre adresse de facturation.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/frFr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const frFr = {
payment: {
title: 'Paiement',
description: 'Tous les paiements sont sécurisés et chiffrés.',
billingInformation: {
title: 'Informations de facturation',
description: 'Saisissez vos informations de facturation.',
},
billingAddress: {
title: 'Adresse de facturation',
description: 'Entrez votre adresse de facturation.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/idId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const idId = {
payment: {
title: 'Pembayaran',
description: 'Semua pembayaran aman dan terenkripsi.',
billingInformation: {
title: 'Informasi penagihan',
description: 'Masukkan informasi penagihan Anda.',
},
billingAddress: {
title: 'Alamat Penagihan',
description: 'Masukkan alamat penagihan Anda.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/itIt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const itIt = {
payment: {
title: 'Pagamento',
description: 'Tutti i pagamenti sono sicuri e crittografati.',
billingInformation: {
title: 'Informazioni di fatturazione',
description: 'Inserisci le informazioni di fatturazione.',
},
billingAddress: {
title: 'Indirizzo di Fatturazione',
description: 'Inserisci il tuo indirizzo di fatturazione.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/ptBr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const ptBr = {
payment: {
title: 'Pagamento',
description: 'Todos os pagamentos são seguros e criptografados.',
billingInformation: {
title: 'Informações de cobrança',
description: 'Insira suas informações de cobrança.',
},
billingAddress: {
title: 'Endereço de Cobrança',
description: 'Digite seu endereço de cobrança.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/qaPs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export const qaPs = {
payment: {
title: '[Þâÿmëñţ Îñförmâţîöñ]',
description: '[Âll þâÿmëñţš ârë šëçürë ând ëñçrÿþţëd för ÿöür šâfëţÿ.]',
billingInformation: {
title: '[Bîllîñg Îñförmâţîöñ]',
description: '[Ëñţër ÿöür bîllîñg îñförmâţîöñ dëţâîlš.]',
},
billingAddress: {
title: '[Bîllîñg Âddrëšš Îñförmâţîöñ]',
description: '[Ëñţër ÿöür bîllîñg âddrëšš dëţâîlš.]',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/trTr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const trTr = {
payment: {
title: 'Ödeme',
description: 'Tüm ödemeler güvenli ve şifrelidir.',
billingInformation: {
title: 'Fatura bilgileri',
description: 'Fatura bilgilerinizi girin.',
},
billingAddress: {
title: 'Fatura Adresi',
description: 'Fatura adresinizi girin.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/viVn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const viVn = {
payment: {
title: 'Thanh toán',
description: 'Tất cả thanh toán đều được bảo mật và mã hóa.',
billingInformation: {
title: 'Thông tin thanh toán',
description: 'Nhập thông tin thanh toán của bạn.',
},
billingAddress: {
title: 'Địa chỉ thanh toán',
description: 'Nhập địa chỉ thanh toán của bạn.',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/zhCn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export const zhCn = {
payment: {
title: '付款',
description: '所有付款均经过安全加密。',
billingInformation: {
title: '账单信息',
description: '请输入您的账单信息。',
},
billingAddress: {
title: '账单地址',
description: '请输入您的账单地址。',
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/zhSg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export const zhSg = {
payment: {
title: '付款',
description: '所有付款都是安全且加密的。',
billingInformation: {
title: '账单信息',
description: '请输入您的账单信息。',
},
billingAddress: {
title: '账单地址',
description: '输入您的账单地址。',
Expand Down
82 changes: 45 additions & 37 deletions packages/react/src/components/checkout/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { type Theme, useTheme } from '@/hooks/use-theme';
import { useVariables } from '@/hooks/use-variables';
import type { TrackingProperties } from '@/tracking/event-properties';
import { TrackingProvider } from '@/tracking/tracking-provider';
import { PaymentMethodType, type CheckoutSession } from '@/types';
import { type CheckoutSession, PaymentMethodType } from '@/types';
import { CheckoutFormContainer } from './form/checkout-form-container';
import type { Target } from './target/target';

Expand Down Expand Up @@ -258,6 +258,9 @@ export function Checkout(props: CheckoutProps) {
? baseCheckoutSchema.extend(checkoutFormSchema)
: baseCheckoutSchema;

const enableBillingAddressCollection =
session?.enableBillingAddressCollection !== false;

return extendedSchema.superRefine((data, ctx) => {
if (data.billingPhone) {
if (!checkIsValidPhone(String(data?.billingPhone))) {
Expand Down Expand Up @@ -285,8 +288,12 @@ export function Checkout(props: CheckoutProps) {
const isPickup = data.deliveryMethod === DeliveryMethods.PICKUP;
const isFreePickup = isFreeOrder && isPickup;

// For free pickup orders, only require first/last name (no address)
if (isFreePickup) {
const requireBillingNamesOnly =
(!enableBillingAddressCollection &&
(!data.paymentUseShippingAddress || isPickup)) ||
isFreePickup;

if (requireBillingNamesOnly) {
const nameFields = [
{ key: 'billingFirstName', message: t.validation.enterFirstName },
{ key: 'billingLastName', message: t.validation.enterLastName },
Expand All @@ -301,40 +308,41 @@ export function Checkout(props: CheckoutProps) {
});
}
}
} else {
// Full billing address validation - required if not using shipping address OR pickup
const requireBillingAddress =
!data.paymentUseShippingAddress || isPickup;

if (requireBillingAddress) {
// Basic billing fields required for all countries
const billingFields = [
{ key: 'billingFirstName', message: t.validation.enterFirstName },
{ key: 'billingLastName', message: t.validation.enterLastName },
{ key: 'billingAddressLine1', message: t.validation.enterAddress },
{ key: 'billingAdminArea2', message: t.validation.enterCity },
{
key: 'billingPostalCode',
message: t.validation.enterZipPostalCode,
},
{ key: 'billingCountryCode', message: t.validation.enterCountry },
];

if (hasRegionData(String(data.billingCountryCode))) {
billingFields.push({
key: 'billingAdminArea1',
message: t.validation.selectState,
});
}
}

const requireBillingAddress =
enableBillingAddressCollection &&
!isFreePickup &&
(!data.paymentUseShippingAddress || isPickup);

for (const { key, message } of billingFields) {
if (!data[key as keyof typeof data]) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message,
path: [key],
});
}
if (requireBillingAddress) {
// Basic billing fields required for all countries
const billingFields = [
{ key: 'billingFirstName', message: t.validation.enterFirstName },
{ key: 'billingLastName', message: t.validation.enterLastName },
{ key: 'billingAddressLine1', message: t.validation.enterAddress },
{ key: 'billingAdminArea2', message: t.validation.enterCity },
{
key: 'billingPostalCode',
message: t.validation.enterZipPostalCode,
},
{ key: 'billingCountryCode', message: t.validation.enterCountry },
];

if (hasRegionData(String(data.billingCountryCode))) {
billingFields.push({
key: 'billingAdminArea1',
message: t.validation.selectState,
});
}

for (const { key, message } of billingFields) {
if (!data[key as keyof typeof data]) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message,
path: [key],
});
}
}
}
Expand Down Expand Up @@ -375,7 +383,7 @@ export function Checkout(props: CheckoutProps) {
}
}
});
}, [checkoutFormSchema, t]);
}, [checkoutFormSchema, session?.enableBillingAddressCollection, t]);

const requiredFields = React.useMemo(() => {
return getRequiredFieldsFromSchema(formSchema);
Expand Down
Loading