WordPress.org

Ready to get started?Download WordPress

Forums

Easy Digital Downloads
[resolved] Getting all payments of the download (4 posts)

  1. Ahaenor
    Member
    Posted 1 year ago #

    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/

  2. 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 );
  3. Ahaenor
    Member
    Posted 1 year ago #

    Pippin, ok, thanks again. This will help.

  4. Great, let me know if you have further questions.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.