'Insert Base64 Image into Woocommerce "ThankYou" E-Mail
I want to include a Base64 Image inline or as attachment to the auto generated thankyou email after each order.
I run a plugin that creates a QR code for each order for online payment. I display the generated qr code (Base64) on the thankyou page. But now I want to send it also via E-Mail.
I'm using the following hooks:
add_action( 'woocommerce_email_after_order_table', 'xyz_email_after_order_table', 10, 4 );
And my function looks like this:
function xyz_email_after_order_table( $order, $sent_to_admin, $plain_text, $email ) {
if ( !empty($order->order_total) && (float)$order->order_total > 0 && $order->get_payment_method() == 'bacs' ) {
$exploded = explode(',', xyz_get_qrcode($order->order_total, $order->id), 2); // limit to 2 parts, i.e: find the first comma
$encoded = $exploded[1]; // pick up the 2nd part
$message = '<p>' . THANKYOU_EMAIL . '<br> <img src="cid:0123456789"></p> ';
$message .= "--boundary" . "\n";
$message .= 'Content-Type: image/png; name="sig.png"' . "\n";
$message .= 'Content-Disposition: inline; filename="sig.png"' . "\n";
$message .= "Content-Transfer-Encoding: base64";
$message .= "Content-ID: <0123456789>" . "\n";
$message .= "Content-Location: sig.png". "\n";
$message .= "\n";
$message .= "base64 " . $encoded;
$message .= "--boundary";
echo $message;
}
}
But sadly this doesn't work. I think the boundary part is at the wrong place. What hook can I use to access the end of the email?
Thanks for any help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
