Core-Commerce Receipt.php

Permalink
$mh = Loader::helper('mail');
$htmlContent = '<img src="http://www.site.com/test/images/logo.jpg" alt="logo" /><br/>';//.... the rest of the html
$mh->setBody(strip_tags($htmlContent));
$mh->setBodyHtml($htmlContent);
// the rest of the $mh calls...


I'm trying to attach a logo to my receipt.php file with the code above.

This isn't throwing any errors but, I'm not seeing the logo I was hoping for. I double checked the link and I can see the logo in browser just fine. The source in my mail client isn't showing the img tag either. Even when I just put text in that code and take out the img html tag its not showing up.

Is it even possible to put a logo with the receipt?

bryanlewis
 
tomreitz replied on at Permalink Reply
tomreitz
strip_tags() removes any markup tags... including <img>

EDIT: (won't let me delete...)
wait, scratch that. I see you're just doing strip_tags on the plaintext version.

I'd have to see the whole code... my guess is that the receipt email is being generated somewhere else in the code.
bryanlewis replied on at Permalink Reply
bryanlewis
Here is the whole thing. Thanks for the help. I really appreciate it!

<?php   defined('C5_EXECUTE') or die(_("Access Denied."));
$mh = Loader::helper('mail');
$htmlContent = '<img src="http://www.site.com/test/images/logo.jpg" alt="logo" /><br/>testing1234<br/>';//.... the rest of the html
$mh->setBody(strip_tags($htmlContent));
$mh->setBodyHtml($htmlContent);
// the rest of the $mh calls...
$body .= $blurb . "\n\n";
$body .= "========== ORDER INFORMATION ==========\n";
$body .= "Order ID: ".$orderID."\n";
$body .= "Total: ".$totalAmount."\n";
for ($i = 0; $i < count($products); $i++) {
   $body .= "Product #" . ($i+1) . ": " . $products[$i]['name'];
    if (count($products[$i]['attributes'])) {
        $body .= " (" . implode(",", $products[$i]['attributes']) . ")";
    }
tomreitz replied on at Permalink Reply
tomreitz
Look for this code somewhere below what you posted:
$mh->setBody(strip_tags($body));
$mh->setBodyHtml($body);


If it's there, then your $htmlContent is just being overwritten with $body. The solution would be to replace your three lines with
$body .= "<img ... whatever /><br />"
bryanlewis replied on at Permalink Reply
bryanlewis
That is showing the html but isn't showing the actual image. weird.
tomreitz replied on at Permalink Reply
tomreitz
Does the receipt email even have an HTML version when you receive it? Maybe it's only sending out a text version...

My only advice is to look through the code below what you posted (or in other files if that's all there is).
bryanlewis replied on at Permalink Reply
bryanlewis
Yea I don't think its possible. Its not working no matter what I do.
bryanlewis replied on at Permalink Reply
bryanlewis
Right now I've moved on to the packages->core_commerce->libraries->payment->controller.php file.

I'm overriding this by putting it in the libraries->payment->controller.php file

In the function sendReceiptEmail I'm putting the following code (*see below)...

Its finding the logo but its not showing the rest of the message ( order ) in html. When I view the source of email the information comes through but I'm not seeing it unless I view the source code in my mail client.

Any thought on how to get the rest of the email to show up without having to view the source?

protected function sendReceiptEmail($order, $data=null) {
          $mh = Loader::helper('mail');
          $htmlContent = '<img src="http://www.site.com/test/images/logo.jpg" alt="logo" /><br/>';
          $mh->setBody(strip_tags($htmlContent));
      $mh->setBodyHtml($htmlContent);
      $pkg = Package::getByHandle('core_commerce');
      $fromE = $pkg->config('EMAIL_RECEIPT_EMAIL');
          $fromN = $pkg->config('EMAIL_RECEIPT_NAME');
          if ($fromE != '') {
             $mh->from($fromE, $fromN);
          }
          $mh->to($order->getOrderEmail());
      $this->setEmailData($mh, $order, $data);
      $blurb = $pkg->config('RECEIPT_EMAIL_BLURB');
      if (empty($blurb)) {
tomreitz replied on at Permalink Reply
tomreitz
can you post the source of the email message? I'm guessing that there may be a problem in the markup that prevents part of the message from being displayed... a la:
<table>
   <tr><td>This table row would be displayed</td></tr>
   <tr <td>This table row would probably not be displayed</td></tr>
</table>
AVL replied on at Permalink Reply
AVL
Any success in modifying the email receipt? Getting it to show HTML? I'd be interested in learning about anything you've found out. Thanks!
cannonf700 replied on at Permalink Reply
cannonf700
Bryan,
Did you ever get this worked out? I have a client that wants to send a receipt that uses a logo and some font coloring...

Thanks,
Ryan Vars
AVL replied on at Permalink Reply
AVL
Hi Ryan,

I found a person who made the changes to my files for me. I posted his contact and a review in this thread:http://www.concrete5.org/community/forums/jobs1/add-attributes-to-e...

Amanda