moved logic into function

Moved the logic that checks whether a user has purchased a item into a method inside the functions_book.php file