Post by Van Quyen » Thu May 12, 2022 1:21 am

Hi
I have added product image for invoice email as below, opencart 3.0.3.8

In catalog/controller/mail/order.php file
Find each $this->load->model('tool/upload');
Add below $this->load->model('catalog/product');
Find each $data['products'][] = array(
Add above $product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
Add below 'thumb' => $order_info['store_url'] . 'image/' . $product_info['image'],

in catalog/view/theme/default/template/mail/order_add.twig
Add <img src="{{ product.thumb }}" width="" height="" /> to position display

Any problem with this way? i want to load products image for email invoice from $this->load->model('tool/image'); but it doesn't work.
Anyone have another solution? please help
Thank you very much!

Newbie

Posts

Joined
Wed Jan 09, 2019 3:36 pm

Post by straightlight » Thu May 12, 2022 8:47 am

Van Quyen wrote:
Thu May 12, 2022 1:21 am
Hi
I have added product image for invoice email as below, opencart 3.0.3.8

In catalog/controller/mail/order.php file
Find each $this->load->model('tool/upload');
Add below $this->load->model('catalog/product');
Find each $data['products'][] = array(
Add above $product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
Add below 'thumb' => $order_info['store_url'] . 'image/' . $product_info['image'],

in catalog/view/theme/default/template/mail/order_add.twig
Add <img src="{{ product.thumb }}" width="" height="" /> to position display

Any problem with this way? i want to load products image for email invoice from $this->load->model('tool/image'); but it doesn't work.
Anyone have another solution? please help
Thank you very much!
Please refer to your catalog/controller/product/product.php and look for: $this->model_tool_image lines.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Van Quyen » Thu May 12, 2022 6:29 pm

Thanks 'straightlight'... It is working with this final solution

In catalog/controller/mail/order.php file
Find each: $this->load->model('tool/upload');
Add below
$this->load->model('catalog/product');
$this->load->model('tool/image');

Find each: $data['products'][] = array(
Add above
$product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], 100, 100);
} else {
$image = $this->model_tool_image->resize('placeholder.png', 100, 100);
}
Add below
'thumb' => $image,

in catalog/view/theme/default/template/mail/order_add.twig
Add <img src="{{ product.thumb }}" /> to position display

Newbie

Posts

Joined
Wed Jan 09, 2019 3:36 pm

Post by kupikocke » Tue Dec 06, 2022 7:37 pm

Hi guys.
I'd like to set the image in email for customer and admin, but I have 3.0.3.6 version.
If the configuration is the same, I only have one qiestion. I don't know how to set up this: "Add <img src="{{ product.thumb }}" /> to position display" in order_add.twig file. Can you please help me?
Thank you.
Greetings.
Martina

Newbie

Posts

Joined
Sat Dec 26, 2020 6:51 pm

Post by unex256 » Fri Jan 13, 2023 3:32 pm

kupikocke wrote:
Tue Dec 06, 2022 7:37 pm
Hi guys.
I'd like to set the image in email for customer and admin, but I have 3.0.3.6 version.
If the configuration is the same, I only have one qiestion. I don't know how to set up this: "Add <img src="{{ product.thumb }}" /> to position display" in order_add.twig file. Can you please help me?
Thank you.
Greetings.
Martina
For anyone in the future, as this was posted fairly long ago:

The most basic solution:

Add:

Code: Select all

<img src="{{ product.thumb }}"/>
After:

Code: Select all

{% for product in products %}
    <tr><td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;">
It will look like this:

Code: Select all

{% for product in products %}
    <tr>
      <td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;">
        <img src="{{ product.thumb }}"/>
        {{ product.name }}
          {% for option in product.option %}<br />
          &nbsp;<small> - {{ option.name }}: {{ option.value }}</small>{% endfor %}
      </td>
Be carefull, as it goes inside the <td></td>, if you put it to the side, the columns will get messed up.

I made it more beautiful by adding another header with text: "photo" and then added the "<img src="{{ product.thumb }}"/>" to a new <td> tag before the one we put it inside before.

You also need to change "colspan=4" to a 5, cause it will be misaligned.

Newbie

Posts

Joined
Tue Feb 16, 2021 11:00 pm
Who is online

Users browsing this forum: No registered users and 97 guests