Add all the spells you need into the spell book.
Use Player Enable/disable ability to disable the abilities (not the spell book) initially. When you buy the ability, enable the ability for the buying player. When you buy again (check for ability level > 0), increase the level of the ability you buy.