• Resolved Uriahs Victor

    (@uriahs-victor)


    I’m working on an Addon for EDD and I’d like to get the user ID of users who have purchased a product.

    Example, if a download has the ID 52, the function would work similar to this:

    $user_ids = edd_get_customers_for_download(52);
    print_r($user_ids, true);
    
    // Outputs array of user ids

    I was able to achieve this in WooCommerce by querying the woocommerce_downloadable_product_permissions for the product ID and getting back a list of the user IDs because that table also has a column for user_id

    I tried finding a similar table/relationship for EDD and unfortunately can’t figure it out yet

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Mihai Joldis

    (@misulicus)

    Hye @uriahs-victor

    We don’t have an easy way to do it right now (It will be easier with EDD 3.0) but what you could do is follow the way the Sales reporting works for specific downloads. When you got the Downloads page the “Sales” column shows the number of sales for each download and if you click on the number it loads the reports page wher you can see more info and also Customer details that purchased it.

    Following the code of that page you could put something together for your use case.
    If you look at the code her https://github.com/easydigitaldownloads/easy-digital-downloads/blob/master/includes/admin/reporting/class-sales-logs-list-table.php#L307-L326 its something you could use, with changes ofcourse.

    You would take all the $logs for a specific download then go through each of the returned logs and retrieved the payment and from that you can get your Customer object (https://docs.easydigitaldownloads.com/article/1004-eddcustomer) and from that you can retrieve your email, user_id or any other info you might need.

    All this should be easier to do with EDD 3.0 but for now that would be the only way.

    Plugin Support Mihai Joldis

    (@misulicus)

    Because there have not been any recent updates to this topic we’ll be changing the status to resolved. If you have any further questions you can start a new thread or head over to our support page to submit your request if it is related to one of our available extensions

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Function to get customers of a download product’ is closed to new replies.