Skip to content

Instantly share code, notes, and snippets.

@ultimatemember
Last active November 5, 2015 19:07
Show Gist options
  • Save ultimatemember/afb94c5b66c63a34d3c1 to your computer and use it in GitHub Desktop.
Save ultimatemember/afb94c5b66c63a34d3c1 to your computer and use it in GitHub Desktop.

Revisions

  1. Ultimate Member renamed this gist May 4, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Ultimate Member renamed this gist May 4, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. Ultimate Member created this gist May 4, 2015.
    49 changes: 49 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    // recent payments
    function sc_edd_recent_payments( $atts ) {

    $p_query = new EDD_Payments_Query( array(
    'number' => 12,
    'status' => 'publish'
    ) );

    $payments = $p_query->get_payments();

    if ( $payments ) { ?>
    <div class="table recent_purchases edd-frontend-purchases">
    <table>
    <tbody>
    <?php
    $i = 0;
    foreach ( $payments as $payment ) {

    $i++;

    $items = '';
    $saved = 0;
    foreach($payment->cart_details as $k => $arr ) {
    $saved = $saved + $arr['discount'];
    $items .= '<span>' . $arr['name'] .'</span>';
    }

    if ( $saved > 0 ) {
    $discount = '<span class="edd_price_save">&mdash; Saved <span>$' . $saved . '</span> on this order with a discount code</span>';
    } else {
    $discount = '';
    }

    $when = human_time_diff( strtotime( $payment->date ), current_time('timestamp') );
    $when = '<span class="edd_bought_when">&mdash; ' . $when . ' ago</span>';

    ?>
    <tr style="<?php if ( $i == count( $payments ) ) { echo 'opacity:0.4;'; } ?> <?php if ( $i == count( $payments ) - 1 ) { echo 'opacity:0.8;'; } ?>">
    <td class="edd_order_amount"><span class="edd_price_label"><?php echo edd_currency_filter( edd_format_amount( $payment->total ), edd_get_payment_currency_code( $payment->ID ) ); ?></span></td>
    <td class="edd_order_label">Someone bought <span class="edd_items_bought"><?php echo $items; ?></span> <?php echo $discount; ?> <?php echo $when; ?></td>
    </tr>
    <?php
    } // End foreach ?>
    </tbody>
    </table>
    </div>
    <?php }
    }
    add_shortcode( 'edd_recent_payments', 'sc_edd_recent_payments' );