- Use Shopify’s Storefront API from custom template JavaScript to fetch storefront product and collection data.
- Read and update selected Shopify customer metafields through the Firmhouse Shopify API proxy.
Before you start
These features are available when the Shopify subscriptions app is configured for the Firmhouse project. You also need access to Customer Portal in the Firmhouse sidebar so you can manage Customer Portal v2 settings and edit templates.Use the Shopify Storefront API
Customer Portal v2 includes Liquid tags that output the Shopify store domain and the Storefront API public access token for the project. Use these tags in a template when you want to make client-side requests to Shopify’s Storefront GraphQL API:Rotate the storefront token
Firmhouse caches the Storefront API token and exposes it to Customer Portal v2 templates with{% shopify_storefront_access_token %}.
To rotate the token:
- Open Customer Portal in the Firmhouse sidebar.
- Stay on the Overview page.
- Find Shopify storefront token.
- Click Rotate token.
Allow customer metafields
The Shopify API proxy only allows customer metafields that are explicitly listed in the Customer Portal settings. To allow metafields:- Open Customer Portal in the Firmhouse sidebar.
- Stay on the Overview page.
- Find Shopify API proxy.
- Enter allowed keys as a space-separated list in
namespace.keyformat. - Save the settings.
Read a customer metafield
Customer Portal v2 templates include ashopify_customer_metafields_url Liquid variable. Use it as the same-origin endpoint for reading and updating allowed Shopify customer metafields.
This endpoint is scoped to the Shopify customer linked to the current subscription.
null values.
Update a customer metafield
Use aPATCH request to update an allowed customer metafield.
type, Firmhouse uses single_line_text_field.
Troubleshooting
The Storefront API token is empty Check that the Shopify subscriptions app is configured for the project. The metafield request returns forbidden Check that the metafield is listed under Customer Portal > Overview > Shopify API proxy. The allowed key must match the requestednamespace.key exactly.
The metafield request says no Shopify customer is linked
The current Firmhouse subscription must be linked to a Shopify customer before Customer Portal v2 can read or update Shopify customer metafields.
The update request fails
Check that the request includes namespace, key, and value. For PATCH requests from custom JavaScript, also include the X-CSRF-Token header from the page’s CSRF meta tag.