I use drupal commerce trying to build a website which sells content (nodes with restricted access). The thing is that, if user have bought the product once, he shouldn't have a possibility to do it again.
Currently i'm using
form_commerce_add_to_cart_form_alter to check if user has already added this product to cart and if yes - hide "Add to Cart" button to prevent doing it twice and set a text that this very product is already in the cart. It works totally fine.
What I want to do next are two things:
1) to check if this current user has this product under active (not canceled and not complete) order, and if yes - hide "Add to cart button" and set a text that this product is under order processing at now.
2) to check if this current user has purchased this very product ever before and if he has, do the same trick - hide "Add to cart button" and set a text that User already owns this product.
My problem is that I'm very new to commerce and unfortunately totally don't understand how can I get all orders for the current user and check for some product IDs there... Will be very appreciated for any advice or a tip. Thanks a lot!