Shops let players buy and sell goods for coin. A shop is just a mobile marked as a shopkeeper, so everything in All about Mobiles applies to it too. Money is the usual gold / silver / copper — 1 gold = 100 silver, 1 silver = 100 copper.
A shopkeeper sells the items it holds (each at its value) and buys sellable items from players (at a discount — its rate). The coins it pays out come from its own till, so a shop can run short of money until it earns more.
A shopkeeper is a mobile with data shopkeeper true. Make it npc as well, so it can't be dragged into a fight:
mob create grocer mob grocer data shopkeeper true mob grocer data npc true
An item is worth whatever its value says, written in coins. Anything with no value (or a value of zero) can't be bought or sold.
To put goods on the shelves, give the shopkeeper items you've priced — giving is just a plain hand-over, so the item drops straight into the shop, for sale. By default an item is one of a kind: once a player buys it, it's gone. Mark an item data stock true and the shop never runs out of it (each sale hands the buyer a fresh copy):
item create torch item torch data value 5 copper item torch data stock true give torch grocer
The grocer now sells torches forever. (A shop also re-sells items players bring in — see below — but those are finite and vanish once bought.)
A shop buys items players sell it, then re-sells them at full value. Two fields control the buying side:
mob grocer data rate 40 pays 40%.
to pay with: mob grocer data gold 20. When the till is empty the shop can't buy
until it earns more (players buying from it top it up).
A shop won't buy junk, cursed, donated or garbage goods (the sort that pile up in the recycling and the dump), nor anything with no value.
These work whenever a shopkeeper is in the room:
mob create blacksmith mob blacksmith data shopkeeper true mob blacksmith data npc true mob blacksmith data rate 40 mob blacksmith data gold 25 item create dagger item dagger data value 2 silver item dagger data stock true give dagger blacksmith
The blacksmith now sells daggers (2 silver each, never out of stock) and buys blades adventurers bring in at 40% of their value, paying from a 25-gold till.