0

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.

  • 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
1
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy