Making WordPress.org


Ignore:
Timestamp:
05/11/2016 11:21:02 PM (8 years ago)
Author:
iandunn
Message:

WordCamp Budgets: Attach a PDF copy of the invoice to the notification email.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/sponsor-invoices-dashboard.php

    r3109 r3119  
    323323    $invoice_url  = admin_url( sprintf( 'post.php?post=%s&action=edit', $invoice_id ) );
    324324    $headers      = array( 'Reply-To: support@wordcamp.org' );
     325    $attachments  = array();
     326    $attachment_message = '';
     327    $invoice_filename = false;
     328    // todo realign
    325329
    326330    if ( 'approved' === $new_status ) {
     
    328332        $sponsor_email  = get_post_meta( $sponsor_id, '_wcpt_sponsor_email_address',  true );
    329333        $status_message = "has been sent to $sponsor_name via $sponsor_email. You will receive another notification when they have paid the invoice.";
     334        $qbo_invoice_id   = get_post_meta( $invoice_id, '_wcbsi_qbo_invoice_id', true );
     335        $invoice_filename = \WordCamp_QBO_Client::get_invoice_filename( $qbo_invoice_id );
     336        // todo realign
     337
     338        if ( ! is_wp_error( $invoice_filename ) ) {
     339            $attachments[]      = $invoice_filename;
     340            $attachment_message = "\nA copy of the invoice has been attached to this message, in case you need to follow up with the sponsor.";
     341        }
    330342    } elseif ( 'paid' === $new_status ) {
    331343        $status_message = "has been paid by $sponsor_name. Go ahead and publish them to your website!";
     
    340352
    341353        $invoice_url
     354        $attachment_message
    342355
    343356        If you have any questions, please reply to let us know."
    344357    );
    345358
    346     wp_mail( $to, $subject, $message, $headers );
     359    wp_mail( $to, $subject, $message, $headers, $attachments );
     360
     361    if ( $invoice_filename ) {
     362        unlink( $invoice_filename );
     363    }
    347364
    348365    restore_current_blog();
Note: See TracChangeset for help on using the changeset viewer.