• Resolved aintzim

    (@aintzim)


    Hey im using the WooCommerce PDF Invoices & Packing Slips, and I need to attached the invoice to a custom email and i can′t find de way, this is my custom email function:

    function virtual_sent($order_id, $checkout=null) {
    global $woocommerce;
    $order = new WC_Order( $order_id );
    if($order->status === ‘virtual-shipment’ ) {

    //I TRIED THIS BUT IT DOESNT WORK
    /*$invoice = new BEWPI_Invoice( $order->get_order_number() ); // use $order->id when using older WC version.
    $invoice_path = $invoice->get_full_path();
    $attachments[] = $invoice_path;*/

    // Create a mailer
    $mailer = $woocommerce->mailer();

    $message_body = get_virtual_email_html( $order, $subject, $mailer );

    $message = $message_body ;

    $mailer->send( $order->billing_email, sprintf( __( “\xE2\x9C\x8A” ), $order->get_order_number() ), $message);

    }

    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hi @aintzim

    BEWPI_Invoice is not a class from our plugin, i think you posted in the wrong forum.

    • This reply was modified 4 years, 8 months ago by alexmigf.
    Thread Starter aintzim

    (@aintzim)

    Yeah i know now, but there is any way i can attach the invoice to a custom email?

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @aintzim

    What you want to achieve will require some custom development from your side.

    I will give you some inputs, you should be able to go further with this.

    You can access the order document from here: wcpdf_get_invoice()

    You should include the PDF path in the mailer command like this:

    WC()->mailer()->send( $order->get_billing_email(), $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = array('path/to/invoice.pdf') );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I attach a PDF invoice to my custom email template?’ is closed to new replies.