You could compare gold...but indexing the item would be much safer and probably just as easy.
Alternatively you could go so far as to trigger the buying, but I feel like that is a waste of effort.
Last suggestion would be kind of dumb but..when a unit buys an item, save their gold, have them instantly sell it, check the difference in gold, divide it by the sell factor (usually .5) and there was your price.