Metafeilds Value to Showing in Product

Metafeilds Value to Showing in Product

cwsg
New Member
5 0 0

I put a value within Metafield 'label' through Shopify API.But The Label field Value not Showing within Products.But,When We Put The Metafield Value Manually, it's Showing In Products. Please Guide Us Why this Metafields value not showing while adding value through Shopify API. 

Replies 2 (2)

JuneN
Shopify Partner
132 6 38

Hi @cwsg 

 

A possible reason is that the theme you're using does not include a text field for metafields by default. This means that you will need to add the text field manually in order to be able to enter values for your metafield. To add the text field for your metafield, you will need to edit the theme code for your store.

If you find my suggestion helpful, please give it a like or mark it as a solution!
And discover more approaches to:
Streamline invoicing process Boost sales with labels & badges Add social proofs & create FOMO
Or get valuable updates and private deals regarding Shopify here.

Vinsinfo
Shopify Partner
392 138 132

@cwsg Kindly check below steps you have used to put value to metafield label. Let me know whether it is helpful for you.

 

We can update the metafield values in two ways.

 

 

WAY 1:

1. To set and update metafiled value for a product, you can use below endpoint and method.

Endpoint: {store_URL}/admin/api/2024-04/products/{product_id}/metafields.json
Method: POST
Request body:

 

{
    "metafield": {
        "key": "your_metafield_key",
        "value": "your_metafield_value",
        "type": "your_metafield_type",
        "namespace": "your_metafield_namespace"
    }
}

 

 

Check this document for adding a metafield value to existing product: https://shopify.dev/docs/api/admin-rest/2024-01/resources/metafield#post-blogs-blog-id-metafields

 

 

WAY 2:

This is another way to set and update the metafield value. If you used this way, please check whether you have followed the below instructions.

 

1. To set metafiled value for product for the first time, we have to use below endpoint and method.
Endpoint: {store_URL}/admin/api/2024-04/products/{product_id}.json
Method: PUT
Request body:

 

{
    "product": {
        "id": product_id,
        "metafields": [
            {
                "key": "your_metafield_key",
                "value": "your_metafield_value",
                "type": "your_metafield_type",
                "namespace": "your_metafield_namespace"
            }
        ]
    }
}

 

 

 

Note: This API call works only to set a metafield value for existing product for the first time.
Check this document for adding a metafield value to existing product: https://shopify.dev/docs/api/admin-rest/2024-04/resources/product#put-products-product-id
 
2. To update a metafield value, we need to use below endpoints and methods.
i) First we have to use below endpoint to get a metafield id
Endpoint: {store_URL}/admin/api/2024-04/products/{product_id}/metafields.json
Method: GET
 
ii) Then by using metafield id, we have to use below endpoints to update the product's metafield value.
Endpoint: {store_URL}/admin/api/2024-04/products/{product_id}/metafields/{metafield_id}.json
Method: PUT
Request body:

 

{
    "metafield": {
        "id": metafield_id,
        "value": "your_metafield_value",
        "type": "your_metafield_type"
    }
}

 

 

 

 
If it doesn't works for you, kindly share the code that you used to help you on this.
 
Please provide your support by click "Like" and "Accepted" if our solution works for you. Thanks for your support.
Please reach out to bizdev@vinsinfo.com for any enquires related to Shopify.
Our Services: Custom Theme Development, Theme Customization, Custom Feature Implementation, Data Migration, Custom APP Development, Website Optimization and Google Merchant Center Support