Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

REST API: Create Product with Harmonized System Code and Country of Origin

Solved

REST API: Create Product with Harmonized System Code and Country of Origin

MaximRIT
Shopify Partner
16 2 3

Hello,

 

I am trying to create a product with few variants and assign them (Harmonized System) HS code and Country of origin. According to this article https://shopify.dev/changelog/the-inventoryitem-resource-now-includes-hs-codes-country-codes-and-pro... HS code should be a product variant metafield. I was unable to find how to specify country of origin just found that inventory item may have them https://shopify.dev/api/admin-rest/2022-01/resources/inventoryitem so tried to try my luck and do something similar for product variant but it doesn't work. Strangely enough but HS code also doesn't work correctly: the metafield is there, I can see it in a browser after adding an item:

MaximRIT_1-1642692484020.png

and the "harmonized_system_code" metafield looks pretty similar when I'm adding HS code to a blank item using  web admin:

 

MaximRIT_0-1642692344461.png

Even more: when I'm opening in web admin the product variant with imported HS code metafield it shown no HS code but if I'll put there HS code and save changes the metafield will be updated with the value I set in web admin.

 

Here is the REST request:

 

 

{
  "product": {
    "title": "Regular T-Shirt Heather Grey",
    "body_html": "<p>The Regular T-Shirt from Japanese based brand Sheltech</p>",
    "vendor": "SHELTEC",
    "product_type": "T-Shirts",
    "published_at": "2020-10-29T17:54:27",
    "published_scope": "global",
    "tags": ["Sub-category:Long Sleeve Tees","Sub-category2:Round Neck","Season:SS20","Colour:Grey","Department:Menswear","Country:Japan","Material:Leather","Brand:SHELTEC","Men"], 
    "variants": [
      {
        "option1": "Size M Color Grey",
        "price": "45", 
        "inventory_management": "shopify",
        "weight": 1,
        "weight_unit": "kg",
        "metafields": [
          {"key":"harmonized_system_code","value":"070110","type":"string","namespace":"global"},  
          {"key":"country_code_of_origin","value":"JP","type":"string","namespace":"global"},
          {"key":"country_code","value":"JP","type":"string","namespace":"global"}  
        ],
        "sku": "11951M",
        "barcode": "11951"
      },
      {
        "option1": "Size L Color Grey",
        "price": "45", 
        "inventory_management": "shopify",
        "weight": 1,
        "weight_unit": "kg",
        "metafields": [
          {"key":"harmonized_system_code","value":"070110","type":"string","namespace":"global"},  
          {"key":"country_code_of_origin","value":"JP","type":"string","namespace":"global"},
          {"key":"country_code","value":"JP","type":"string","namespace":"global"}  
        ],
        "sku": "11952L",
        "barcode": "11952"
      },
      {
        "option1": "Size XL Color Grey",
        "price": "45", 
        "inventory_management": "shopify",
        "weight": 1,
        "weight_unit": "kg",
        "metafields": [
          {"key":"harmonized_system_code","value":"070110","type":"string","namespace":"global"},  
          {"key":"country_code_of_origin","value":"JP","type":"string","namespace":"global"},
          {"key":"country_code","value":"JP","type":"string","namespace":"global"}  
        ],
        "sku": "11953XL",
        "barcode": "11953"
      }
    ],
    "status": "test"
  }
}

 

 

Accepted Solution (1)
MaximRIT
Shopify Partner
16 2 3

This is an accepted solution.

Yes. Actually by some reason Shopify stores HSC and country of origin over inventory items not products. You can use PUT request as it's shown here: https://shopify.dev/docs/api/admin-rest/2024-10/resources/inventoryitem#put-inventory-items-inventor...

View solution in original post

Replies 2 (2)

partner_fitc_ws
Shopify Partner
7 0 0

Just came across this when looking in to something myself.  Did you get to the bottom of the problem in the end and what was the solution?

MaximRIT
Shopify Partner
16 2 3

This is an accepted solution.

Yes. Actually by some reason Shopify stores HSC and country of origin over inventory items not products. You can use PUT request as it's shown here: https://shopify.dev/docs/api/admin-rest/2024-10/resources/inventoryitem#put-inventory-items-inventor...