-
Notifications
You must be signed in to change notification settings - Fork 56
DEVDOCS-6607 - customer form fields #1203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
bc-terra
wants to merge
1
commit into
main
Choose a base branch
from
multi-lang-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| # Translations for Customers (Beta) | ||
|
|
||
| <Callout type='info'> | ||
| The Translations Admin GraphQL API for managing customer translations, including custom form fields and address form fields, is available for Catalyst storefronts only. | ||
| </Callout> | ||
|
|
||
| The Translations Admin GraphQL API provides support for translating customer form fields. This applies to both customer-level and address-level form fields, but the specifics for managing them are slightly different. | ||
|
|
||
| The following entities are translatable for customer form fields: | ||
|
|
||
| - Field Name (`name`) | ||
| - Field Description (`description`) | ||
| - Field Value (`value`) for options in selection-style field types | ||
|
|
||
| <Callout type='warning'> | ||
| While `value` is provided as translatable for customer form fields, it is designed only to support selection field types such as dropdown menus, radio buttons, checkboxes, and other formats where predefined values are available. | ||
| </Callout> | ||
|
|
||
| ## Resource fields | ||
|
|
||
| Customer translation entities have the following resource type and ID formats: | ||
|
|
||
| | Entity Type | `resourceType` | `resourceId` Format | | ||
| |----------------------------|--------------------------|-------------------------------------------------------| | ||
| | Customer Custom Form Field | `CUSTOMER_FORM_FIELDS` | `bc/store/customer-form-field/{{form_field_id}}` | | ||
| | Address Custom Form Field | `ADDRESS_FORM_FIELDS` | `bc/store/address-form-field/{{form_field_id}}` | | ||
|
|
||
| ## Querying Customer-Related Form Field Translations | ||
|
|
||
| Customer-related translations are managed via the Admin GraphQL API, but data is returned in the locale determined by the query. | ||
|
|
||
| ### Example: Query a List of Custom Form Field Translations | ||
|
|
||
| Note that in this example, `resourceType` is referenced with a placeholder. Use the appropriate value for your use case. Further, the example response explicitly shows a customer form field example. Your code should address the appropriate structure for the specific data you query. | ||
|
|
||
| <Tabs items={['Request', 'Response']}> | ||
| <Tab> | ||
|
|
||
| ```graphql filename="Example query: Query a list of custom form field translations" showLineNumbers copy | ||
| GRAPHQL https://api.bigcommerce.com/stores/{{store_hash}}/graphql | ||
| X-Auth-Token: {{token}} | ||
|
|
||
| query { | ||
| store { | ||
| translations( | ||
| filters: { | ||
| resourceType: {{RESOURCE_TYPE}} | ||
| channelId: "bc/store/channel/{{channel_id}}" | ||
| localeId: "bc/store/locale/{{locale_code}}" | ||
| } | ||
| first: 50 | ||
| ) { | ||
| edges { | ||
| node { | ||
| resourceId | ||
| fields { | ||
| fieldName | ||
| original | ||
| translation | ||
| } | ||
| } | ||
| cursor | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| </Tab> | ||
| <Tab> | ||
|
|
||
| ```json filename="Example response: Custom form field translations" showLineNumbers copy | ||
| { | ||
| "data": { | ||
| "store": { | ||
| "translations": { | ||
| "edges": [ | ||
| { | ||
| "node": { | ||
| "resourceId": "bc/store/customer-form-field/17", | ||
| "fields": [ | ||
| { | ||
| "fieldName": "name", | ||
| "original": "Favorite Color", | ||
| "translation": "Couleur Préférée" | ||
| } | ||
| ] | ||
| }, | ||
| "cursor": "eyJpZCI6MTd9" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| </Tab> | ||
| </Tabs> | ||
|
|
||
| ### Single Item, Update, and Delete | ||
|
|
||
| The examples below demonstrate the process for updating and deleting translations. They function analogously for both customer form fields and address form fields. Use the appropriate `resourceType` and `resourceId` for your specific use case. | ||
|
|
||
| #### Example: Update a Customer Address Form Field Translation | ||
|
|
||
| ```graphql filename="Example mutation: Update a customer address form field translation" showLineNumbers copy | ||
| mutation { | ||
| translation { | ||
| updateTranslations( | ||
| input: { | ||
| resourceType: ADDRESS_FORM_FIELDS | ||
| channelId: "bc/store/channel/{{channel_id}}" | ||
| localeId: "bc/store/locale/{{locale_code}}" | ||
| entities: [ | ||
| { | ||
| resourceId: "bc/store/address-form-field/{{form_field_id}}" | ||
| fields: [ | ||
| { fieldName: "name", value: "Numéro d'appartement" } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ) { | ||
| __typename | ||
| errors { | ||
| __typename | ||
| ... on Error { | ||
| message | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### Example: Delete a Customer Address Form Field Translation | ||
|
|
||
| ```graphql filename="Example mutation: Delete a customer address form field translation" showLineNumbers copy | ||
| mutation { | ||
| translation { | ||
| deleteTranslations( | ||
| input: { | ||
| resourceType: ADDRESS_FORM_FIELDS | ||
| channelId: "bc/store/channel/{{channel_id}}" | ||
| localeId: "bc/store/locale/{{locale_code}}" | ||
| resources: [ | ||
| { | ||
| resourceId: "bc/store/address-form-field/{{form_field_id}}" | ||
| fields: ["name", "description"] | ||
| } | ||
| ] | ||
| } | ||
| ) { | ||
| __typename | ||
| errors { | ||
| __typename | ||
| ... on Error { | ||
| message | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.