I don't know of a code to unlock the items but I have found a mod that will put them into the shop, you need to register on their site to download it, and there are still one or two things that I found to be buggy.
But if you just want the two books you can install the mod, then buy the books, you may need to wait till 3am game time for the shop to reset, then save, exit game and remove the mod, this will not damage the game in any way that i noticed, but will probably slow the shop down when you're there due to the number of items it add in. As it adds almost (if not all) quest items, crafting and trading materials into the village shop.
[removed mod link - saltypaws]
Please do not put links that pertain to mods when posting. Thanks