Each Product has a Merchant
field which is standard Craft User
. What I'd like to do is list out all Orders which contain one or more Products relating to the currentUser
. I was hoping I'd be able to use Relations to accomplish this, so something like this:
{% set products = craft.commerce.products({
'relatedTo': currentUser
}) %}
{% set orders = craft.commerce.orders.relatedTo({
'sourceElement': products,
'field': 'lineItems.purchasable.product'
}).find %}
The first query works fine and returns only the Products
relating to the currentUser
, but when I try to use it as the basis for the second query, that's where it collapses in a big heap! Am I in the right ballpark, or isn't this possible in the way I'm trying?
Any help gratefully received.