I'm using Drupal 7 and the Commerce module.
I'm trying to warn the user whenever they add to the cart a product they already own. Getting a list of products already owned by the user (in PHP code) seems quite the challenge, because the connection between Line Item and a Product is in a serialized blob.
I have, as arguments, a list of products currently in the cart, and the user.
If I go the way of EntityFieldQuery, I can easily get all line items pertaining to the given products, but I can't extend the query to filter only completed orders by the given user. (Or can I? That would be great.)
If I go the way of db_select, I can easily get all completed orders for the given user, but I can't bridge the Line Item <-> Product connection.
Any help will be appreciated.