- Posts: 24
- Thank you received: 0
Information mail: add image into message
9 years 6 months ago - 9 years 6 months ago #267009
by simtheo
Information mail: add image into message was created by simtheo
-- url of the page with the problem -- :
www.matabikeshop.com/
Hello.
It's possible to add the product image inside the information mail?
In the information mail there is only the product name (with link to the page) but I need also to see the image after the name.
In the NEW ORDER email there is the product image, but I cannot manage the PHP source code for handle the image inside the information mail.
I found this source code for handle the image but isn't correct. I found it from the PRELOAD VERSIONE section of NEW ORDER confirmation mail:
Thanks for the support.
BR
MatteoS
Hello.
It's possible to add the product image inside the information mail?
In the information mail there is only the product name (with link to the page) but I need also to see the image after the name.
In the NEW ORDER email there is the product image, but I cannot manage the PHP source code for handle the image inside the information mail.
I found this source code for handle the image but isn't correct. I found it from the PRELOAD VERSIONE section of NEW ORDER confirmation mail:
Code:
if(!empty($item->images[0]->file_path) && $config->get('thumbnail', 1) != 0) {
//$img = $imageHelper->getThumbnail($item->images[0]->file_path, array(50, 50), array('forcesize' => true, 'scale' => 'outside'));
$img = $imageHelper->getThumbnail($item->images[0]->file_path, array(150, 150), array('default' => true));
if($img->success) {
if(substr($img->url, 0, 3) == '../')
$image = str_replace('../', HIKASHOP_LIVE, $img->url);
else
$image = substr(HIKASHOP_LIVE, 0, strpos(HIKASHOP_LIVE, '/', 9)) . $img->url;
$cartProduct['PRODUCT_IMG'] = '<img src="'.$image.'" alt="" style="float:left;margin-top:3px;margin-bottom:3px;margin-right:6px;"/>';
}
}
BR
MatteoS
Last edit: 9 years 6 months ago by Jerome. Reason: [code] is nice
Please Log in or Create an account to join the conversation.
9 years 6 months ago #267048
by nicolas
Replied by nicolas on topic Information mail: add image into message
Hi,
The image data is not loaded there. So you'll have to first load that with a MySQL query and then you can use a similar code to get the HTML for the thumbnail.
You can do something like that in the preload:
and then you can use the tag {VAR:PRODUCT_IMG} in the email.
The image data is not loaded there. So you'll have to first load that with a MySQL query and then you can use a similar code to get the HTML for the thumbnail.
You can do something like that in the preload:
Code:
$query = "SELECT * FROM #__hikashop_file WHERE file_ref_id = ".(int)$data->product->product_id." AND file_type='product'";
$db = JFactory::getDBO();
$image = $db->loadObject();
if(!empty($image->file_path)) {
$img = $imageHelper->getThumbnail($image->file_path, array(50, 50), array('forcesize' => true, 'scale' => 'outside'));
if($img->success) {
if(substr($img->url, 0, 3) == '../')
$image = str_replace('../', HIKASHOP_LIVE, $img->url);
else
$image = substr(HIKASHOP_LIVE, 0, strpos(HIKASHOP_LIVE, '/', 9)) . $img->url;
$vars['PRODUCT_IMG'] = '<img src="'.$image.'" alt="" style="float:left;margin-top:3px;margin-bottom:3px;margin-right:6px;"/>';
}
}
Please Log in or Create an account to join the conversation.
9 years 6 months ago #267141
by simtheo
Replied by simtheo on topic Information mail: add image into message
Really thank you.
Unfortunately it doesn't work.
I add some instructions for control the program and I checked that the program doesn't enter not even in the first if.
Why?
The query performed is the seguent:
SELECT * FROM #__hikashop_file WHERE file_ref_id = 758 AND file_type='product'
If I try to perform this query directly on the database, it return the correct result.
Where's the problem?
BR
MatteoS
Unfortunately it doesn't work.
I add some instructions for control the program and I checked that the program doesn't enter not even in the first if.
Why?
The query performed is the seguent:
SELECT * FROM #__hikashop_file WHERE file_ref_id = 758 AND file_type='product'
If I try to perform this query directly on the database, it return the correct result.
Where's the problem?
BR
MatteoS
Please Log in or Create an account to join the conversation.
9 years 6 months ago - 2 years 5 months ago #267147
by simtheo
Replied by simtheo on topic Information mail: add image into message
I modified the program in this way:
Code:
$query = "SELECT * FROM #__hikashop_file WHERE file_ref_id = ".(int)$data->product->product_id." AND file_type='product'";
$db = JFactory::getDBO();
// Reset the query using our newly populated query object.
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__hikashop_file');
$query->where("file_ref_id = ".(int)$data->product->product_id." AND file_type='product'");
$vars['PRODUCT_IMG'] = "SELECT * FROM #__hikashop_file WHERE file_ref_id = ".(int)$data->product->product_id." AND file_type='product'";
$image = $db->loadObject();
if(!empty($image->file_path)) {
$vars['PRODUCT_IMG'] = 'no img';
$img = $imageHelper->getThumbnail($image->file_path, array(150, 150), array('forcesize' => false, 'scale' => 'outside'));
if($img->success) {
$vars['PRODUCT_IMG'] = 'no path';
if(substr($img->url, 0, 3) == '../')
$image = str_replace('../', HIKASHOP_LIVE, $img->url);
else
$image = substr(HIKASHOP_LIVE, 0, strpos(HIKASHOP_LIVE, '/', 9)) . $img->url;
$vars['PRODUCT_IMG'] = '<img src="'.$image.'" alt="" style="float:left;margin-top:3px;margin-bottom:3px;margin-right:6px;"/>';
}
}
Last edit: 2 years 5 months ago by nicolas.
Please Log in or Create an account to join the conversation.
9 years 6 months ago - 2 years 5 months ago #267155
by simtheo
Replied by simtheo on topic Information mail: add image into message
sorry ... this is correct ...
// Reset the query using our newly populated query object.
// Reset the query using our newly populated query object.
Code:
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__hikashop_file');
$query->where("file_ref_id = ".(int)$data->product->product_id." AND file_type='product'");
$vars['PRODUCT_IMG'] = "SELECT * FROM #__hikashop_file WHERE file_ref_id = ".(int)$data->product->product_id." AND file_type='product'";
$image = $db->loadObject();
if(!empty($image->file_path)) {
$vars['PRODUCT_IMG'] = 'no img';
$img = $imageHelper->getThumbnail($image->file_path, array(150, 150), array('forcesize' => false, 'scale' => 'outside'));
if($img->success) {
$vars['PRODUCT_IMG'] = 'no path';
if(substr($img->url, 0, 3) == '../')
$image = str_replace('../', HIKASHOP_LIVE, $img->url);
else
$image = substr(HIKASHOP_LIVE, 0, strpos(HIKASHOP_LIVE, '/', 9)) . $img->url;
$vars['PRODUCT_IMG'] = '<img src="'.$image.'" alt="" style="float:left;margin-top:3px;margin-bottom:3px;margin-right:6px;"/>';
}
}
Last edit: 2 years 5 months ago by nicolas.
Please Log in or Create an account to join the conversation.
9 years 6 months ago - 9 years 6 months ago #267142
by nicolas
Replied by nicolas on topic Information mail: add image into message
Hi,
Ah yes, I forgot to add the line:
$db->setQuery($query);
before the line:
$image = $db->loadObject();
Do that and it should work much better with my version, but yours is good too
Ah yes, I forgot to add the line:
$db->setQuery($query);
before the line:
$image = $db->loadObject();
Do that and it should work much better with my version, but yours is good too
Last edit: 9 years 6 months ago by nicolas.
Please Log in or Create an account to join the conversation.
9 years 6 months ago #267237
by simtheo
Replied by simtheo on topic Information mail: add image into message
Of course
your is better !!!
Really thank you for the support: it works perfectly.
BR
MatteoS
Really thank you for the support: it works perfectly.
BR
MatteoS
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 75
- Thank you received: 4
2 years 5 months ago - 2 years 5 months ago #360859
by Petike1007
Replied by Petike1007 on topic Information mail: add image into message
I have tried your version, but it's always come back with the same product image.
I can see in the query the file_ref_id is 0
Any idea why is that?
I can see in the query the file_ref_id is 0
Any idea why is that?
Last edit: 2 years 5 months ago by Petike1007.
Please Log in or Create an account to join the conversation.
2 years 5 months ago #360860
by nicolas
Replied by nicolas on topic Information mail: add image into message
Hi,
It's been a while since the image of the products in the order is by default included in the order notification emails sent by HikaShop.
So you should not need to do anything to get them displayed and this thread is not relevant anymore.
What are you trying to do ?
It's been a while since the image of the products in the order is by default included in the order notification emails sent by HikaShop.
So you should not need to do anything to get them displayed and this thread is not relevant anymore.
What are you trying to do ?
Please Log in or Create an account to join the conversation.
Time to create page: 0.302 seconds