Hey I am using GraphQL API to fetch list of all products and it’s variants from my store. I am not able to find the HS code tag, I saw one “taxCode” tag in the query but it’s coming blank. I can see the HS code from the frontend UI of the store and got the values for some products but how to get that via API. Also I can see the productType tag in the API (Ex - Shirts) but which field shows it’s parent categories? (Ex. Apparels & Fashions etc.)
Hey @Chanchal_Bhardwaj you should be able to find the product categories and the HS code for a product/variant like this:
{
products(first: 1 reverse: true) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
category {
fullName
parentId
}
variants(first: 10) {
nodes {
id
inventoryItem {
id
harmonizedSystemCode
}
}
}
}
}
}
}
This gives me the following API response on my end here (just as an example):
{
"data": {
"products": {
"pageInfo": {
"hasNextPage": true,
"endCursor": "eyJsYXN0X2lkIjoxMDU4MjA1ODg2MDU2NiwibGFzdF92YWx1ZSI6IjEwNTgyMDU4ODYwNTY2In0="
},
"edges": [
{
"node": {
"id": "gid://shopify/Product/10582058860566",
"category": {
"fullName": "Apparel & Accessories > Clothing > Activewear > Boxing Shorts",
"parentId": "gid://shopify/TaxonomyCategory/aa-1-1"
},
"variants": {
"nodes": [
{
"id": "gid://shopify/ProductVariant/52731544895510",
"inventoryItem": {
"id": "gid://shopify/InventoryItem/54759092355094",
"harmonizedSystemCode": "620520"
}
}
]
}
}
}
]
}
}
The HS code is always going to live under the Variant’s Inventory item data, and if there are any sub categories for a particular product’s Category, the whole “tree” from the parent down to the final sub category should appear under the product category’s “fullname” value - hope this helps. Let me know if we can help out further
Hey @Alan_G Thanks a lot!!
Hey @Alan_G , do you know if I can get gender orientation for products as well from any tag? Also does Shopify store tax% for a HS code?
Hey @Chanchal_Bhardwaj - there’s not a direct way to get the gender info (for example “Kid’s Shirts - Boy”) directly from the HS code unless it’s hardcoded in (like Men’s Suits, for example), if that’s what you were looking for. For more specific info on gender or other categorizations for products, you could use product tags or metafields to store that data.
We only provide the category path of the HS code as it appears in the admin via the API (in the the fullname
value). For pulling the specific tax percentages for a particular HS Code, that’s not something we provide directly on the product object itself, but some import tax information can be pulled on the line item that represents a product on a specific order through the duty object: Duty - GraphQL Admin .
If you did need to calculate further tax information for a specific HS code, a workaround would be using an external API like the CARM API for Canadian duties/taxes (more info here) or the FedEx HS Code API. You could pull the HS Code for a product via the Shopify API and then cross reference it against those external APIs if needed.
Hope this helps!
Thanks @Alan_G, helps a lot!!