Getting the real shirt ID from Template ID

IIRC, aren’t able to get the shirt ID from the decal ID, however you can do the opposite, getting the decal ID from the shirt ID. What I would do instead, is create an IntValue inside of the mannequin and then iterate through all mannequins and give each mannequin the shirt ID to be applied.

For example:

for i,v in pairs(workspace:WaitForChild('Mannequins'):GetChildren()) do
    if v:FindFirstChild('ShirtID') then
        local shirt = v:FindFirstChild('Shirt')
        if not shirt then
            shirt = Instance.new('Shirt')
            shirt.Parent = v -- parent to the mannequin
        end
        shirt.TemplateId = 'rbxassetid://'..v.ShirtID.Value
    else
        warn('No ShirtID value was found inside of '..v.Name..'!')
    end
end

And then for your click detector,

clickDetector.MouseClick:Connect(function(plr)
    local value = clickDetector.Parent:FindFirstChild('ShirtID')
    if value then
        market:PromptPurchase(plr, id)
    end
end

A feature request for this has been created awhile ago but it wasn’t ever addressed.