My plan is to have an item called "Yearly Membership". I need code to see if a person has purchased this item within a year. There are so many tables in zen-cart that I get a little lost figuring out what I need to check for, and how to check it.

How do I do something like:

PSEUDO CODE:

Code:
SELECT orders_id FROM zen_order WHERE customers_id = SESSION_USER_ID and...
after the and would have to check zen_orders_products to match orders_id and products_id to the product id of my membership item, check order_status to make sure it equals 3 and check date_purchased to make sure it is < 365 days old.