Items are purchased from npcs with gold.
Npcs have a limited stock for each item they sell.
Npcs have both a guaranteed item list and a random pool of items they can sell each day, varying based on weather, mood, etc.
Npcs periodically restock their inventory (e.g. after a day passes).
Some items do not restock and are permanently sold out once the player buys them.
Some npcs won't sell the player items until after a quest or dialogue has been completed.
Nps can expand their shop as the player progresses through the game.
Npcs have their own gold and they 'buy' when the player sells items to them.
Npcs have items they like and items that they don't like. This affects the sell price.
There are some items you can't sell like quest-specific items.
Items sold to an npc can be bought back for free until the npc restocks, after which the item disappears.