You can recover the sold item by clicking on the 'cancel' option that appears after selling the item.
There is no time limit for this option.
❗However, it will disappear when you click on another item or in-game icon.

If another item has taken the spot of sold item (ex: anemone seed, butterfly, XPs), then click on 'undo', and the item will return to the waiting list in the center (between the 'inventory' icon and 'shop' icon).

To sum up:
🎯Be careful with generating items & higher-level items.
🎯The ONLY option to retrieve the item is by using the 'cancel' option.
🎯Check the 'waiting list' in case there is no space on the board: