JJS
JJS

Reputation: 6678

Use Product Metafields from Stencil in BigCommerce

Stencil provides access the Custom Fields of a Product in a template file as documented in Product Other Details

{{product.custom_fields}}

{{#each custom_fields}}
<li>{{name}}: {{{value}}}</li>
{{/each}}

How do I access the MetaFields that are created in the Product API
POST /catalog/products/{product_id}/metafields?

Upvotes: 3

Views: 1030

Answers (2)

nate
nate

Reputation: 36

While one cannot natively display product metafields in Stencil, there is an app in the Bigcommerce marketplace that allows one do to so. The app also lets one view, create, update, and delete metafields for products, categories, variants, and brands. You can export metafields and import them with a csv file. The app is not free, however, there is a 7 day free trial. This answer is to give an alternative solution to the problem mentioned.

Upvotes: 0

Karen White
Karen White

Reputation: 2153

Product metafields aren't currently surfaced as a Stencil property. Their original purpose was to store metadata against the product object for backend apps (data like shipping origin for ShipperHQ), so they're available via the REST API but not exposed on the front end. If you wanted to access metafields on the frontend, you could build out middleware (using a serverless function, for example) to call the API and pipe that data to the storefront.

It would be good for us to understand your use case better though. Do you want to display metafield values in the template, or base some kind of frontend logic around their values?

Upvotes: 1

Related Questions