Product Thumbnail In Email

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 9 months ago #87053

Is it possible to add a thumbnail in the order email. I've ordered on sites where you get the email with a photo of what you ordered.

Thanks!!

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

  • Posts: 12953
  • Thank you received: 1778
11 years 9 months ago #87075

Hi,

Sure you'll just have to :
- Go to "Hikashop->System->Mail"
- Edit the "Order status notification" Email
- Add the code to display your picture

Note that this feature is just available in the business edition

Hope this will help you.

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 9 months ago #88218

What code do I add please?

Thanks!!

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

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 9 months ago #88447

You first need to load the image form the database, then display it.

So something like that:

$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__hikashop_file WHERE file_type=\'product\' AND file_ref_id='.$item->product_id);
$image = $db->loadObject();
$imageHelper = hikashop_get('helper.image');
$config =& hikashop_config();
$width = $config->get('thumbnail_x');
$height = $config->get('thumbnail_y');
$imageHelper->checkSize($width,$height,$image);
echo $imageHelper->display($image->file_path,true,$image->file_name,'style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle"', '', $width, $height);
You should add it in the loop displaying the product info.
For example, before the product name display code:
echo $item->order_product_name;

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 9 months ago #88484

Is there any way you can add this to the next upgrade? I think it would be a nice enhancement :)

Thanks!!

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 8 months ago #91499

I add the code to System > Emails > Order status notification but when I received the email I don't see the thumb. Did I miss something?

                    <p>
                      <?php
                    $db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__hikashop_file WHERE file_type=\'product\' AND file_ref_id='.$item->product_id);
$image = $db->loadObject();
$imageHelper = hikashop_get('helper.image');
$config =& hikashop_config();
$width = $config->get('thumbnail_x');
$height = $config->get('thumbnail_y');
$imageHelper->checkSize($width,$height,$image);
echo $imageHelper->display($image->file_path,true,$image->file_name,'style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle"', '', $width, $height);
                      
                       echo $item->order_product_name;
                      if($group){
                        $display_item_price=false;
                        foreach($data->cart->products as $j => $optionElement){
                          if($optionElement->order_product_option_parent_id != $item->order_product_id) continue;
                          if($optionElement->order_product_price>0){
                            $display_item_price = true;
                          }

                        }
                        if($display_item_price){
                          if($config->get('price_with_tax')){
                            echo ' '.$currencyHelper->format($item->order_product_price+$item->order_product_tax,$data->order_currency_id);
                          }else{
                            echo ' '.$currencyHelper->format($item->order_product_price,$data->order_currency_id);
                          }
                        }
                      } ?>
                    </p>

Thanks!!

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

  • Posts: 13201
  • Thank you received: 2322
11 years 8 months ago #91653

Hi,

In the SQL request, you have to change "#_" with your table prefix, for example 'jos' if Joomla 1.5.

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 7 months ago #93726

Looks good!! Thank you! :)

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 6 months ago #102310

When the product has a Characteristics (Variants) added to it, the product image does not come into the email, it sends the default image (barcode.png) :(

Is there a way to have it email the image of the main product IF an image is not added to the Characteristics (Variants)? Because I would have to add the image to all the variants and it is not necessary in this case as the variants are only sizes.

Thanks!!

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

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 6 months ago #102488

You need to use the main product id in that case instead of the variant product id:

$id = $item->product_id;
if(!empty($item->order_product_parent_id)){
 foreach($data->cart->products as $j => $optionElement){
  if($optionElement->order_product_id != $item->order_product_parent_id) continue;
  $id = $optionElement->product_id;
 }
}
$db->setQuery('SELECT * FROM #__hikashop_file WHERE file_type=\'product\' AND file_ref_id='.$id);

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 5 months ago #103140

I'm looking at this but I'm not sure what I'm replacing :( and I don't want to mess things up so can you please tell me what to replace this with?

Thank you!!

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

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 5 months ago #103244

It's that line that you need to replace with that code:

$db->setQuery('SELECT * FROM #__hikashop_file WHERE file_type=\'product\' AND file_ref_id='.$item->product_id);

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 5 months ago #103460

I am clearly not understanding what you are instructing me to do here. I replaced the code as per below but now I am not getting any images at all in the "order admin" or "order created" emails :(

I add this code to replace the line of code that was there. What am I missing please?

$id = $item->product_id;
if(!empty($item->order_product_parent_id)){
 foreach($data->cart->products as $j => $optionElement){
  if($optionElement->order_product_id != $item->order_product_parent_id) continue;
  $id = $optionElement->product_id;
 }
}
$db->setQuery('SELECT * FROM mlg__hikashop_file WHERE file_type=\'product\' AND file_ref_id='.$id);
             <p style="margin-right:5px;">
                      <?php
                    $db = JFactory::getDBO();

$id = $item->product_id;
if(!empty($item->order_product_parent_id)){
 foreach($data->cart->products as $j => $optionElement){
  if($optionElement->order_product_id != $item->order_product_parent_id) continue;
  $id = $optionElement->product_id;
 }
}
$db->setQuery('SELECT * FROM mlg__hikashop_file WHERE file_type=\'product\' AND file_ref_id='.$id);
               
$image = $db->loadObject();
$imageHelper = hikashop_get('helper.image');
$config =& hikashop_config();
$width = $config->get('thumbnail_x');
$height = $config->get('thumbnail_y');
$imageHelper->checkSize($width,$height,$image);
echo $imageHelper->display($image->file_path,true,$image->file_name,'style="margin-top:10px;margin-bottom:5px;margin-right:10px;display:inline-block;vertical-align:middle"', '', $width, $height);
 
                       echo $item->order_product_name;
                      if($group){
                        $display_item_price=false;
                        foreach($data->cart->products as $j => $optionElement){
                          if($optionElement->order_product_option_parent_id != $item->order_product_id) continue;
                          if($optionElement->order_product_price>0){
                            $display_item_price = true;
                          }
 
                        }
                        if($display_item_price){
                          if($config->get('price_with_tax')){
                            echo ' '.$currencyHelper->format($item->order_product_price+$item->order_product_tax,$data->order_currency_id);
                          }else{
                            echo ' '.$currencyHelper->format($item->order_product_price,$data->order_currency_id);
                          }
                        }
                      } ?>
            </p>

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

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 5 months ago #103462

Hi,

Please use the code we gave you.
So, you have to paste this:

$db->setQuery('SELECT * FROM #__hikashop_file WHERE file_type=\'product\' AND file_ref_id='.$id);;
But not this:
$db->setQuery('SELECT * FROM mlg__hikashop_file WHERE file_type=\'product\' AND file_ref_id='.$id);
(Your database prefix should not be filled, it could but at this moment, you have too much underlines characters).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 11 years 5 months ago by Jerome.

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 5 months ago #103463

I tried that but ONLY items without characteristics are showing the thumbs. Products with characteristics are not showing the thumbs :(

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

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 5 months ago #103473

Hi,

Ok.
Personally, I preferred SQL request than PHP code:

$id = (int)$item->product_id;
$query = 'SELECT * FROM #__hikashop_file as f INNER JOIN #__hikashop_product as p ON (f.file_ref_id = p.product_id OR f.file_ref_id = p.product_parent_id) WHERE f.file_type=\'product\' AND p.product_id = '.$id.' ORDER BY f.file_ordering';
$db->setQuery($query);

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 11 years 5 months ago by Jerome.

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 5 months ago #103484

OK so now the characteristics thumbs are showing however the main product image is wrong - the title of the product is correct but somehow it picked up the wrong image. I added a "Dress" to the cart but a "Sunglasses" image showed up in the email. The title is correct though.

So to clarify, an image of the sunglasses came in the email with the title of the dress that I add.

Thanks!!

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

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 5 months ago #103506

I don't see how that's possible.
Can you check the images of your product ? Where does that sunglass image comes from ?

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
11 years 5 months ago #103677

Hi Nicolas,

The sunglasses is in the "Accessories > Sunglasses" category.

I have attached an image so that you can see what I mean. Also, below is the code:

<p style="margin-right:5px;">
                      <?php
                    $db = JFactory::getDBO();
$id = (int)$item->product_id;
$query = 'SELECT * FROM #__hikashop_file as f INNER JOIN #__hikashop_product as p ON (f.file_ref_id = p.product_id OR f.file_ref_id = p.product_parent_id) WHERE f.file_type=\'product\' AND p.product_id = '.$id.' ORDER BY f.file_ordering';
$db->setQuery($query);

$image = $db->loadObject();
$imageHelper = hikashop_get('helper.image');
$config =& hikashop_config();
$width = $config->get('thumbnail_x');
$height = $config->get('thumbnail_y');
$imageHelper->checkSize($width,$height,$image);
echo $imageHelper->display($image->file_path,true,$image->file_name,'style="margin-top:10px;margin-bottom:5px;margin-right:10px;display:inline-block;vertical-align:middle"', '', $width, $height);
 
                       echo $item->order_product_name;
                      if($group){
                        $display_item_price=false;
                        foreach($data->cart->products as $j => $optionElement){
                          if($optionElement->order_product_option_parent_id != $item->order_product_id) continue;
                          if($optionElement->order_product_price>0){
                            $display_item_price = true;
                          }
 
                        }
                        if($display_item_price){
                          if($config->get('price_with_tax')){
                            echo ' '.$currencyHelper->format($item->order_product_price+$item->order_product_tax,$data->order_currency_id);
                          }else{
                            echo ' '.$currencyHelper->format($item->order_product_price,$data->order_currency_id);
                          }
                        }
                      } ?>
            </p>

Thank you!!

Attachments:

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

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 5 months ago #103834

Hi,

Maybe you have an image with the file_ref_id set to 0 (which is not good).
Please update the query to exclude these files:

$query = 'SELECT * FROM #__hikashop_file as f INNER JOIN #__hikashop_product as p ON (f.file_ref_id = p.product_id OR f.file_ref_id = p.product_parent_id) WHERE f.file_type=\'product\' AND p.product_id = '.$id.' AND f.file_ref_id != 0 ORDER BY p.product_id DESC, f.file_ordering';
Thanks,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.110 seconds
Powered by Kunena Forum