Information mail: add image into message

  • Posts: 24
  • Thank you received: 0
7 years 8 months ago #267009

-- 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:

		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;"/>';
			}
		}
Thanks for the support.

BR

MatteoS

Attachments:
Last edit: 7 years 8 months ago by Jerome. Reason: [code] is nice

Please Log in or Create an account to join the conversation.

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
7 years 8 months ago #267048

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:

$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;"/>';
			}
		}
and then you can use the tag {VAR:PRODUCT_IMG} in the email.

Please Log in or Create an account to join the conversation.

  • Posts: 24
  • Thank you received: 0
7 years 8 months ago #267141

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

Please Log in or Create an account to join the conversation.

  • Posts: 24
  • Thank you received: 0
7 years 8 months ago #267147

I modified the program in this way:

$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: 7 months 1 week ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 24
  • Thank you received: 0
7 years 8 months ago #267155

sorry ... this is correct ...

// 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: 7 months 1 week ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
7 years 8 months ago #267142

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 :)

Last edit: 7 years 8 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 24
  • Thank you received: 0
7 years 8 months ago #267237

Of course ;-) your is better !!!
Really thank you for the support: it works perfectly.

BR

MatteoS

Please Log in or Create an account to join the conversation.

  • Posts: 75
  • Thank you received: 4
7 months 1 week ago #360859

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?

Last edit: 7 months 1 week ago by Petike1007.

Please Log in or Create an account to join the conversation.

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
7 months 1 week ago #360860

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 ?

Please Log in or Create an account to join the conversation.

Time to create page: 0.077 seconds
Powered by Kunena Forum