Shopify custom field extension in your stack lets you fetch the products/items of your Shopify store and display them on your entry page via a field. While creating entries, you can select one or more listed products as an input value for this field.
This step-by-step guide explains how to create a Shopify custom field extension for your content types in Contentstack. The steps performed are as follows:
- Add the “Shopify” custom field extension to your stack
- Use your custom field
Add the “Shopify” custom field extension to your stack
- Go to your stack, navigate to the “Settings” gear icon, and select Extensions.
- On the Extensions page, click on the + Add Extension button, and select Create new. If you have not added any extensions in the stack yet, click on the create a new one link as shown below.
- In the Select Extension Type window, select Custom Field.
- On the Create New Extension page, enter values in the fields as given below:
- Title (required): Provide a suitable title, for example “Shopify,” for your custom field. This title will be visible when you select the extension in the custom field in your content type.
- Field Data Type (required): Select the data type in which the input data of the field should be saved in Contentstack. In this case, select Text.
- Multiple (optional): Leave this field unchecked.
- Hosting method (required): Select Hosted by Contentstack as the hosting method for this content type.
- Extension Source Code (required): Specify the extension code here. Download the source code for the extension and add it here.
- Config Parameter (required):You need to provide the domain of your application and the access token of the Shopify Storefront API in this field.
Note: To retrieve the "Access Token" of Storefront API, refer to the documentation.
Save the custom field.
Now, let’s understand how you can start using this custom field in your content type.
Use your custom field
Once you have added a custom field, you can use it in your content type like any other field. To add a custom field in your content type, perform the following steps:
Create a content type and add the Custom field to it.
Under Select Extension, select the “Shopify” field that you created and set the other properties. You can add other fields as per requirements.
- Finally, click on either Save or Save and Close to save your changes.
- Next, create an entry for this content type, and you will see the Shopify field in action.