WoW:USERAPI GetSellValue
![]() |
This article or section contains information that is out-of-date.
|
← AddOn defined functions < GetSellValue
The intent of this page is to provide a simple, consistent API for addons to query the vendor sell value of an item without the need to individually support every sell value addon in existence. All sell value addons are asked to provide the following global function:
sellToVendorPrice = GetSellValue(item);
Requirements[edit]
- 'item' must take the same values GetItemInfo does
- Must return an int, or nil if unknown price. Only return 0 if you know the item cannot be sold to vendor.
Recommended[edit]
Check for existence of the global before you define it and hook it if present. This allows for other sell value addons to provide prices that are not known by your addon.
Example Code[edit]
The following code snippets illustrate how to create a hook capable of accepting the same input values as GetItemInfo.
Tekkub's version[edit]
This code will ensure that YourItemPriceFunc is passed an integer itemid, or the hooked function is called if present and your function does not return a value. It is optimized to take advantage of tail calls and avoid useless hook calls.
local origGetSellValue = GetSellValue function GetSellValue(item) local id = type(item) == "number" and item or type(item) == "string" and tonumber(item:match("item:(%d+)")) if not id and type(item) == "string" then -- Convert item name to itemid, only works if the player has the item in his bags local _, link = GetItemInfo(item) id = link and tonumber(link:match("item:(%d+)")) end return id and (YourItemPriceFunc(id) or origGetSellValue and origGetSellValue(id)) end
Polarina's version[edit]
Functionally this is the same as Tekkub's version. Just slightly slower due to the extra select() call.
local origGetSellValue = GetSellValue function GetSellValue(item) local id, sellval if type(item) == "number" then id = item else -- Acquire the second argument from GetItemInfo. local link = select(2, GetItemInfo(item)) -- Check if 'link' is set before using it. id = link and tonumber(link:match("item:(%d+)")) end if id then sellval = -- Retrieve the price here... end -- If 'sellval' is not set, fall back to origGetSellValue. return sellval or (id and origGetSellValue and origGetSellValue(id)) end
Addons[edit]
This function is implemented by the following addons:
- Informant of the Auctioneer AddOns Package by The Auctioneer AddOns Team.
- ItemDataCache (v1.11 and higher).
- ItemPriceTooltip by Bam.
- SellFish by Tuller.
- Valuation by Polarina.
- Auctionator by Zirco.
- AuctionLite by Merial.
Addons using this function:
- VendorBait by Tekkub
- FuBar_GarbageFu
See also: