Identifying trade skill mat type by subclass ID

If I want to identify that an item is a tradeskill mat, I can check the class ID to see if it’s equal to Enum.ItemClass.Tradegoods:

local link = C_Container.GetContainerItemLink(bag, slot)
local classID, subclassID = select(12, GetItemInfo(link))
if (classID == Enum.ItemClass.Tradegoods) then
    do something...

But if I want to go further and identify what type of crafting material it is, such as Leather or Cloth, I can’t find a similar Enum for the subclassID in this list of Enums. I could just print the subclassID values for different crafting mats & hard code some constants but I’d really rather use something from the API so the code won’t be fragile.

Is there some other resource I should be looking at for API constants? Or is there another way to do this that’s better than looking at the subclassID?

i dont think so. Enum.ItemTradegoodsSubclass doesnt exist, so you can roll your own, and/or use libPeriodicTable until blizzard get around to creating one.

this is from part of my code.

			TRADEGOODS = {
				PARENT = LE_ITEM_CLASS_TRADEGOODS or Enum.ItemClass.Tradegoods or 7,
				TRADEGOODS = 0,
				PARTS = 1,
				EXPLOSIVES = 2,
				DEVICES = 3,
				JEWELCRAFTING = 4,
				CLOTH = 5,
				LEATHER = 6,
				METAL_AND_STONE = 7,
				COOKING = 8,
				HERBS = 9,
				ELEMENTAL = 10,
				OTHER = 11,
				ENCHANTING = 12,
				MATERIALS = 13,
				ITEM_ENCHANTMENT = 14,
				WEAPON_ENCHANTMENT = 15,
				INSCRIPTION = 16,
				EXPLOSIVES_AND_DEVICES = 17,
			},
1 Like

Thanks. I took a look at libPeriodicTable but that seems like overkill for what I’m doing so I guess I’ll just hard-code it.