Reputation: 517
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.
https://i.sstatic.net/7vPSd.jpg - Example of Embedded App fields to be saved.
https://i.sstatic.net/bxDFT.jpg - Example of product listing.
Upvotes: 1
Views: 49
Reputation: 20422
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.
Upvotes: 1