Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using the eCommerce plugin Dukapress for my WordPress website. I want to attach the invoice PDF to the admin's email, but I'm not sure how to go about this. I'm under the impression that the only way you can do this is through editing the php files contained in the plugins folder, wp_content/plugins/dukapress/dukapress.php.

This code is from Dukapress's dukapress.php file

function dpsc_pnj_send_mail($to, $from, $name, $subject, $msg, $attachment = FALSE) 
{
    global $wpdb;
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: ' . $name . ' <' . $from . '>' . "\r\n";
    if ($attachment = TRUE) 
    {
        if ($dp_shopping_cart_settings['dp_shop_pdf_generation'] === 'checked') 
        {
            $mail_attachment = array(DP_PLUGIN_DIR. '/pdf/invoice_' . $attachment . '.pdf');
            @wp_mail($to, $subject, $msg, $headers, $mail_attachment);
        }
        else    
        {
            @wp_mail($to, $subject, $msg, $headers);
        }
    }
    else 
    {
        @wp_mail($to, $subject, $msg, $headers);
    }
}

I've already tried changing $attachment = FALSE to $attachment = TRUE, but it didn't make any difference. I can also settle for having the PDF's information displayed in the email instead of attached in a separate file if that's easier. Any suggestions will be greatly appreciated, even if I am way off.

share|improve this question
    
if ($attachment = TRUE) is always going to evaluate to true because the = operator assigns a value. What you want do to is compare a value, so in this case you'd use the == operator. –  Ian Dunn Feb 12 '12 at 17:59
add comment

migrated from stackoverflow.com Feb 3 '12 at 20:18

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 1 down vote accepted
function dpsc_pnj_send_mail($to, $from, $name, $subject, $msg, $attachment = FALSE) {
    global $wpdb;
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: ' . $name . ' ' . $from . '' . "\r\n";   
    if ($attachment) {
        if ($dp_shopping_cart_settings['dp_shop_pdf_generation'] === 'checked') {
            $mail_attachment = array(DP_PLUGIN_DIR. '/pdf/invoice_' . $attachment . '.pdf');
            @wp_mail($to, $subject, $msg, $headers,$mail_attachment);
        }
        else {
            @wp_mail($to, $subject, $msg, $headers);
        }
    }
    else {
        @wp_mail($to, $subject, $msg, $headers);
    }
}

The above is the code we're using on another site. Works.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.