Skip to content

Commit 8f87408

Browse files
authored
Merge pull request #2714 from Shopify/zhuo/customer/3p-dev-field-market/country
[Customer][EXT] add country to customer account Standard API.
2 parents 9e26bd3 + 3fd8062 commit 8f87408

File tree

12 files changed

+43
-24
lines changed

12 files changed

+43
-24
lines changed

.changeset/fluffy-dolls-rule.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions-react': minor
3+
---
4+
5+
Provide useLocalizationCountry hook to customer-account extension targets

.changeset/funny-dragons-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions': minor
3+
---
4+
5+
Add country to customer account Standard API.

packages/ui-extensions-react/src/surfaces/customer-account/hooks/country.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import {
22
Country,
3-
RenderOrderStatusExtensionTarget,
3+
RenderExtensionTarget,
44
} from '@shopify/ui-extensions/customer-account';
55

66
import {useApi} from './api';
77
import {useSubscription} from './subscription';
88
import {ExtensionHasNoFieldError} from '../errors';
99

1010
/**
11-
* Returns the country of the checkout, and automatically re-renders
12-
* your component if the country changes.
11+
* Returns the country associated with either the current order on the order status page
12+
* or the selected country in the customer account interface,
13+
* and automatically re-renders your component if the country changes.
1314
*/
1415
export function useLocalizationCountry<
15-
Target extends RenderOrderStatusExtensionTarget = RenderOrderStatusExtensionTarget,
16+
Target extends RenderExtensionTarget = RenderExtensionTarget,
1617
>(): Country | undefined {
1718
const api = useApi<Target>();
1819
const extensionTarget = api.extension.target;

packages/ui-extensions/docs/surfaces/customer-account/reference/apis/localization.doc.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ const data: ReferenceEntityTemplateSchema = {
2020
"Returns the buyer's language, as supported by the extension. If the buyer's actual language is not supported by the extension, it will return the fallback locale used for translations.",
2121
type: 'UseLanguageGeneratedType',
2222
},
23+
{
24+
title: 'useLocalizationCountry',
25+
description:
26+
"Returns the country of the buyer's current session, and automatically re-renders your component if the country changes.",
27+
type: 'UseLocalizationCountryGeneratedType',
28+
},
2329
{
2430
title: 'useExtensionLanguage',
2531
description:

packages/ui-extensions/src/shared.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,14 @@ export type CountryCode =
860860
| 'ZW'
861861
| 'ZZ';
862862

863+
export interface Country {
864+
/**
865+
* The ISO-3166-1 code for this country.
866+
* @see https://www.iso.org/iso-3166-country-codes.html
867+
*/
868+
isoCode: CountryCode;
869+
}
870+
863871
// For instructions on how to update this list see: https://github.com/Shopify/checkout-web/pull/39534
864872
/**
865873
* A union of keys for the localized fields that are required by certain countries.

packages/ui-extensions/src/surfaces/checkout.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export type {
4242
I18n,
4343
I18nTranslate,
4444
Currency,
45-
Country,
4645
Market,
4746
Language,
4847
Localization,

packages/ui-extensions/src/surfaces/checkout/api/address-autocomplete/standard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type {
33
AppMetafieldEntry,
44
Capability,
55
CheckoutToken,
6-
Country,
76
Currency,
87
Editor,
98
ExtensionSettings,
@@ -19,6 +18,7 @@ import type {
1918
import type {Attribute, MailingAddress} from '../shared';
2019
import type {
2120
ApiVersion,
21+
Country,
2222
GraphQLError,
2323
StorefrontApiVersion,
2424
Timezone,

packages/ui-extensions/src/surfaces/checkout/api/standard/standard.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
ApiVersion,
1313
Capability,
1414
CurrencyCode,
15+
Country,
1516
CountryCode,
1617
Timezone,
1718
GraphQLError,
@@ -334,14 +335,6 @@ export interface Currency {
334335
isoCode: CurrencyCode;
335336
}
336337

337-
export interface Country {
338-
/**
339-
* The ISO-3166-1 code for this country.
340-
* @see https://www.iso.org/iso-3166-country-codes.html
341-
*/
342-
isoCode: CountryCode;
343-
}
344-
345338
export interface Market {
346339
/**
347340
* A globally-unique identifier for a market.

packages/ui-extensions/src/surfaces/customer-account/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export type {
2424
CartCustomDiscountAllocation,
2525
AppliedGiftCard,
2626
Currency,
27-
Country,
2827
Market,
2928
DeliveryGroup,
3029
DeliveryGroupType,
@@ -47,6 +46,7 @@ export type {
4746
export type {
4847
Attribute,
4948
CurrencyCode,
49+
Country,
5050
CountryCode,
5151
Timezone,
5252
GraphQLError,

packages/ui-extensions/src/surfaces/customer-account/api/order-status/order-status.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {StatefulRemoteSubscribable} from '@remote-ui/async-subscription';
22

33
import type {
44
CurrencyCode,
5-
CountryCode,
5+
Country,
66
Timezone,
77
SellingPlan,
88
Attribute,
@@ -122,14 +122,6 @@ export interface Currency {
122122
isoCode: CurrencyCode;
123123
}
124124

125-
export interface Country {
126-
/**
127-
* The ISO-3166-1 code for this country.
128-
* @see https://www.iso.org/iso-3166-country-codes.html
129-
*/
130-
isoCode: CountryCode;
131-
}
132-
133125
export interface Market {
134126
/**
135127
* A globally-unique identifier for a market.

0 commit comments

Comments
 (0)