WordPress.org

Support

Support » Plugins and Hacks » Easy Digital Downloads » [Resolved] Getting all payments of the download

[Resolved] Getting all payments of the download

  • Hello!

    I’d want to get all edd_payment posts (or just their IDs), related to one download (or to a group of a several ones).

    But it seems to me that a relation between payments and downloads is possible only through serialized array in metadata fields. It makes impossible to get all related edd_payment posts else than from a bruteforce running over.

    Am i miss something, like a some function like edd_get_payments($download_id)?

    I’m using EDD 1.5.1.

    P.S. Another idea i have is to use $edd_logs somehow. Is it possible?

    Thank you in advance.

    http://wordpress.org/extend/plugins/easy-digital-downloads/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Pippin Williamson

    @mordauk

    Pippin's Plugins and Plugin Reviewer

    You cannot retrieve the payments directly, but you can retrieve the log entries that relate to the payments.

    When a purchase is made, a payment is created that has all products purchased listed in a serialized array, and then a log entry is created for each individual product that is purchased.

    You can retrieve the payment logs for any product like this:

    global $edd_logs;
    $args = array( 'post_parent' => '23', 'log_type' => 'sale', 'posts_per_page' => 30 );
    $sales = $edd_logs->get_connected_logs( $args );

    The results will be a standard WordPress query object.

    Replace 23 with the product ID and 30 with the number of results you want to return.

    If you need to get the associated payment IDs then, you can use:

    $payment_id = get_post_meta( $log_id, '_eddd_log_payment_id', true );

    Pippin, ok, thanks again. This will help.

    Plugin Author Pippin Williamson

    @mordauk

    Pippin's Plugins and Plugin Reviewer

    Great, let me know if you have further questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Getting all payments of the download’ is closed to new replies.
Skip to toolbar