Catalog and inventory
GraphQL Admin API
Product custom fields

Product custom fields

International Enhancements for Multi-Storefront

This feature is currently available for Enterprise stores and Partner Sandboxes. If the feature is not working as expected, please contact technical support, as the feature likely needs to be enabled for the individual store. To become an enterprise customer, contact your BigCommerce Customer Service Manager or our support team (opens in a new tab).

Using the Catalog features of the Admin API, you can localize custom fields for a product in a storefront channel.

You must first create the custom field through the control panel or Create product custom field endpoint of the REST Management API.

You can perform the following:

For a full schema, see the GraphQL Admin API reference (opens in a new tab).

Input fields

Setting or removing information requires that you specify ID fields in the input. For more information on how to specify ID fields, see Input fields.

Set product custom fields

The following example sets custom fields for the global store and the specified channel locale.

Example mutation: Set product custom fields
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
mutation ($input: UpdateProductCustomFieldsInput!) {
  product {
    updateProductCustomFields (input: $input) {
      product {
        customFields {
          edges {
            node {
              id
 
              # For the global store
              name
              value
 
              # For the channel locale
              overrides (context: { channelId: "bc/store/channel/1", locale: "en-US" }) {
                edges {
                  node {
                  ... on ProductCustomFieldOverridesForChannelLocale {
                      name
                      value
                      isVisible
                      context {
                        channelId
                        locale
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
GraphQL variables
{
  "input": {
    "productId": "bc/store/product/111",
    "data": [
      {
        "customFieldId": "bc/store/productCustomField/1",
 
        // For the global store
        "name": "Global custom field name",
        "value": "Global custom field value",
 
        // For the channel locale
        "overrides": [
          {
            "channelLocaleOverrides": {
              "context": {
                "channelId": "bc/store/channel/1",
                "locale": "en-US"     
              },
              "data": {
                "name": "Custom field name override",
                "value": "Custom field value override",
                "isVisible": true
              }
            }
          }
        ]
      }
    ]
  }
}

Remove product custom fields for a locale

The following example removes product custom fields for the specified channel locale.

Omitting the attributes field from the input removes all overrides for the custom fields from the locale.

Example mutation: Remove product custom fields for a locale
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
mutation ($input: RemoveProductCustomFieldsOverridesInput!) {
  product {
    removeProductCustomFieldsOverrides(input: $input) {
      product {
        customFields {
          edges {
            node {
              id
 
              # For the global store
              name
              value
 
              # For the channel locale
              overrides (context: { channelId: "bc/store/channel/1", locale: "en-US" }) {
                edges {
                  node {
                    ... on ProductCustomFieldOverridesForChannelLocale {
                      name
                      value
                      isVisible
                      context {
                        channelId
                        locale
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
GraphQL variables
{
  "input": {
    "productId": "bc/store/product/111",
    "data": [
      {
        "customFieldId": "bc/store/productCustomField/1",
        "channelLocaleContextData": {
          "context": {
            "channelId": "bc/store/channel/1",
            "locale": "en-US"
          },
          "attributes": ["NAME", "VALUE", "IS_VISIBLE"]
        }
      }
    ]
  }
}

Query product custom fields

The following example retrieves custom fields. You can retrieve global information for the store and overrides for the specified channel locale.

Example query: Get product custom fields
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/graphql
X-Auth-Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
 
query {
  store {
    product(id: "bc/store/product/111") {
      customFields {
        edges {
          node {
            id
 
            # For the global store
            name
            value
 
            # For the channel locale
            overrides (context: { channelId: "bc/store/channel/1", locale: "en-US" }) {
              edges {
                node {
                  ... on ProductCustomFieldOverridesForChannelLocale {
                    name
                    value
                    isVisible
                    context {
                      channelId
                      locale
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Did you find what you were looking for?