Is It Possible To Store Product Fields And Tie Them Into Liquid Templeting?

- 1 answer

Is it possible to store fields into variables for individual products to use elsewhere in the code or am I stuck with only API calls?

I'd like to store data for each product into a variables and pass them to the liquid product template to make a dynamic hyperlink for each product. - Example of Embedded App fields to be saved. - Example of product listing.



You can use metafields to store and display custom properties of a product.

To save a metafield in your app make a request to the Shopify API:

POST /admin/products/#{id}/metafields.json
  "metafield": {
    "namespace": "test_app",
    "key": "seller_id",
    "value": 123,
    "value_type": "integer"

To get seller_id in the product template:

{{ product.metafields.test_app.seller_id }}

Metafields are available automatically in the templates.