diff --git a/.changeset/green-monkeys-sell.md b/.changeset/green-monkeys-sell.md new file mode 100644 index 00000000..4c6029cd --- /dev/null +++ b/.changeset/green-monkeys-sell.md @@ -0,0 +1,6 @@ +--- +"@godaddy/react": patch +"@godaddy/localizations": patch +--- + +Add additional targets and extend billing flows with localization updates diff --git a/packages/localizations/src/deDe.ts b/packages/localizations/src/deDe.ts index 11d375a8..fef69ee0 100644 --- a/packages/localizations/src/deDe.ts +++ b/packages/localizations/src/deDe.ts @@ -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.', diff --git a/packages/localizations/src/enAu.ts b/packages/localizations/src/enAu.ts index d7610972..68fbe932 100644 --- a/packages/localizations/src/enAu.ts +++ b/packages/localizations/src/enAu.ts @@ -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.', diff --git a/packages/localizations/src/enIe.ts b/packages/localizations/src/enIe.ts index 450a28d1..68ba1989 100644 --- a/packages/localizations/src/enIe.ts +++ b/packages/localizations/src/enIe.ts @@ -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.', diff --git a/packages/localizations/src/enUs.ts b/packages/localizations/src/enUs.ts index db18689c..e277395d 100644 --- a/packages/localizations/src/enUs.ts +++ b/packages/localizations/src/enUs.ts @@ -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.', diff --git a/packages/localizations/src/esAr.ts b/packages/localizations/src/esAr.ts index ae62fa8e..f33b6b42 100644 --- a/packages/localizations/src/esAr.ts +++ b/packages/localizations/src/esAr.ts @@ -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.', diff --git a/packages/localizations/src/esCl.ts b/packages/localizations/src/esCl.ts index 6dd7c8fa..63f0e714 100644 --- a/packages/localizations/src/esCl.ts +++ b/packages/localizations/src/esCl.ts @@ -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.', diff --git a/packages/localizations/src/esCo.ts b/packages/localizations/src/esCo.ts index 6fc6b6d8..e2600cac 100644 --- a/packages/localizations/src/esCo.ts +++ b/packages/localizations/src/esCo.ts @@ -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.', diff --git a/packages/localizations/src/esEs.ts b/packages/localizations/src/esEs.ts index ff845f89..7a69fddd 100644 --- a/packages/localizations/src/esEs.ts +++ b/packages/localizations/src/esEs.ts @@ -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.', diff --git a/packages/localizations/src/esMx.ts b/packages/localizations/src/esMx.ts index 06f4698d..6921355f 100644 --- a/packages/localizations/src/esMx.ts +++ b/packages/localizations/src/esMx.ts @@ -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.', diff --git a/packages/localizations/src/esPe.ts b/packages/localizations/src/esPe.ts index b8c82659..db814e89 100644 --- a/packages/localizations/src/esPe.ts +++ b/packages/localizations/src/esPe.ts @@ -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.', diff --git a/packages/localizations/src/esUs.ts b/packages/localizations/src/esUs.ts index e4ab2386..ec9e146f 100644 --- a/packages/localizations/src/esUs.ts +++ b/packages/localizations/src/esUs.ts @@ -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.', diff --git a/packages/localizations/src/frCa.ts b/packages/localizations/src/frCa.ts index d139fb4f..a1f95e85 100644 --- a/packages/localizations/src/frCa.ts +++ b/packages/localizations/src/frCa.ts @@ -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.', diff --git a/packages/localizations/src/frFr.ts b/packages/localizations/src/frFr.ts index 27702e17..ad94eef2 100644 --- a/packages/localizations/src/frFr.ts +++ b/packages/localizations/src/frFr.ts @@ -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.', diff --git a/packages/localizations/src/idId.ts b/packages/localizations/src/idId.ts index ebbe647d..09b61197 100644 --- a/packages/localizations/src/idId.ts +++ b/packages/localizations/src/idId.ts @@ -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.', diff --git a/packages/localizations/src/itIt.ts b/packages/localizations/src/itIt.ts index fd98b6d3..85d5e0a2 100644 --- a/packages/localizations/src/itIt.ts +++ b/packages/localizations/src/itIt.ts @@ -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.', diff --git a/packages/localizations/src/ptBr.ts b/packages/localizations/src/ptBr.ts index f4cb7c27..57048a4a 100644 --- a/packages/localizations/src/ptBr.ts +++ b/packages/localizations/src/ptBr.ts @@ -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.', diff --git a/packages/localizations/src/qaPs.ts b/packages/localizations/src/qaPs.ts index 91ad583f..6e99184c 100644 --- a/packages/localizations/src/qaPs.ts +++ b/packages/localizations/src/qaPs.ts @@ -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š.]', diff --git a/packages/localizations/src/trTr.ts b/packages/localizations/src/trTr.ts index 339867c4..fed8b55e 100644 --- a/packages/localizations/src/trTr.ts +++ b/packages/localizations/src/trTr.ts @@ -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.', diff --git a/packages/localizations/src/viVn.ts b/packages/localizations/src/viVn.ts index a496cdc0..474b874b 100644 --- a/packages/localizations/src/viVn.ts +++ b/packages/localizations/src/viVn.ts @@ -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.', diff --git a/packages/localizations/src/zhCn.ts b/packages/localizations/src/zhCn.ts index d5c0e2a2..d7c2403b 100644 --- a/packages/localizations/src/zhCn.ts +++ b/packages/localizations/src/zhCn.ts @@ -90,6 +90,10 @@ export const zhCn = { payment: { title: '付款', description: '所有付款均经过安全加密。', + billingInformation: { + title: '账单信息', + description: '请输入您的账单信息。', + }, billingAddress: { title: '账单地址', description: '请输入您的账单地址。', diff --git a/packages/localizations/src/zhSg.ts b/packages/localizations/src/zhSg.ts index de14b637..bb855e68 100644 --- a/packages/localizations/src/zhSg.ts +++ b/packages/localizations/src/zhSg.ts @@ -90,6 +90,10 @@ export const zhSg = { payment: { title: '付款', description: '所有付款都是安全且加密的。', + billingInformation: { + title: '账单信息', + description: '请输入您的账单信息。', + }, billingAddress: { title: '账单地址', description: '输入您的账单地址。', diff --git a/packages/react/src/components/checkout/checkout.tsx b/packages/react/src/components/checkout/checkout.tsx index 934f02b8..e07c2d3a 100644 --- a/packages/react/src/components/checkout/checkout.tsx +++ b/packages/react/src/components/checkout/checkout.tsx @@ -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'; @@ -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))) { @@ -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 }, @@ -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], + }); } } } @@ -375,7 +383,7 @@ export function Checkout(props: CheckoutProps) { } } }); - }, [checkoutFormSchema, t]); + }, [checkoutFormSchema, session?.enableBillingAddressCollection, t]); const requiredFields = React.useMemo(() => { return getRequiredFieldsFromSchema(formSchema); diff --git a/packages/react/src/components/checkout/line-items/line-items.tsx b/packages/react/src/components/checkout/line-items/line-items.tsx index 196e9315..9bd26b95 100644 --- a/packages/react/src/components/checkout/line-items/line-items.tsx +++ b/packages/react/src/components/checkout/line-items/line-items.tsx @@ -1,6 +1,7 @@ // import { Badge } from "@/components/ui/badge"; import { Image } from 'lucide-react'; +import { Target } from '@/components/checkout/target/target'; import { useFormatCurrency } from '@/components/checkout/utils/format-currency'; import { Button } from '@/components/ui/button.tsx'; import { useGoDaddyContext } from '@/godaddy-provider'; @@ -76,6 +77,7 @@ export function DraftOrderLineItems({ return (