How to display product image in invoice?

  • Posts: 6
  • Thank you received: 0
8 years 2 months ago #230806

-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.4.8

HI,
I want to show product image in invoice. What code should I add in the invoice file in Display -> View?
Thanks!!

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
8 years 2 months ago #230834

Hi,

You can try with that:

<?php
		$imageHelper = hikashop_get('helper.image');
		if(!empty($product->images[0]->file_path) && $config->get('thumbnail', 1) != 0) {
			$img = $imageHelper->getThumbnail($product->images[0]->file_path, array(50, 50), array('forcesize' => true, 'scale' => 'outside'));
			if($img->success) {
				echo '<img src="'.$img->url.'" alt="" style="float:left;margin-top:3px;margin-bottom:3px;margin-right:6px;"/>';
			}
		} ?>
in the file "invoice" of the view "order" via the menu Display>Views
For example, before the line:
<?php echo $product->order_product_name;?>

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

  • Posts: 6
  • Thank you received: 0
8 years 1 month ago #232812

hi Nicolas, thanks for your help.
However, it doesnt work. There's still no product image in invoice.

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
8 years 1 month ago #232818

Hi,

Which invoice are you talking about ? The PDF one ? The one the customer can print on the frontend ? The one the merchant can print on the backend ? Something else ?
Are you sure you're editing the view file for the correct template ?
Because that code is only for the invoice in the backend and will only work if you're editing the view file for your backend template.

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

  • Posts: 10
  • Thank you received: 0
5 years 11 months ago #292197

I am using HikaShop Business 2.6.3 and have the same problem. I added the codes in the invoice file of view of order as shown above, but nothing happened. Please help. Your help would be greatly appreciated!

thanks

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

  • Posts: 26004
  • Thank you received: 4004
  • MODERATOR
5 years 11 months ago #292198

Hello,

Even if it was for "manlui", the previous questions are still pending.

Which invoice are you talking about ? The PDF one ? The one the customer can print on the frontend ? The one the merchant can print on the backend ? Something else ?
Are you sure you're editing the view file for the correct template ?


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.

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

  • Posts: 10
  • Thank you received: 0
5 years 11 months ago #292236

I am talking about the invoice that the merchant can print on the backend. The INVOICE file that I edited is shown below:

Display- View - invoice

Client: Back end
Template: isis
View: order
File: invoice

thanks again!

Have a great day!

Attachments:

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
5 years 11 months ago #292239

Hi,

Then please try to also change the line:
$order = $class->loadFullOrder($order_id);
to:
$order = $class->loadFullOrder($order_id, true);
in the file administrator/components/com_hikashop/views/order/view.html.php and that should help.

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

  • Posts: 10
  • Thank you received: 0
5 years 11 months ago #292270

Hi Nicolas,

Thanks for your quick reply!

I just made the change according to your suggestion, but the product images did not show up, instead, my all orders on backend invoice are missing.

Please help.

thanks again

Attachments:

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
5 years 11 months ago #292282

Hi,

I don't see why it would do that.
So if you revert the change, do you confirm that you get back the products ?

I did test the change on my end, but that was on HikaShop 3.4.0, and it worked just fine. I had a look at the code of your version of HikaShop and didn't see why it wouldn't work the same.
I'm afraid it will require hiring a developer to help you with that customization in order to debug the issue.

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

  • Posts: 10
  • Thank you received: 0
5 years 11 months ago #292296

Hello Nicolas,

Thanks for your quick reply!

Before I move on to find a solution, can you please confirm I am using the right codes in INVOICE file that I edited as shown in the attachment.

Display- View - invoice
Client: Back end
Template: isis
View: order
File: invoice

Thanks again!

Have a wonderful one!

Attachments:

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
5 years 11 months ago #292314

Hi,

That looks correct yes.

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

  • Posts: 10
  • Thank you received: 0
5 years 11 months ago #292332

Hello Nicolas,

Thank you so much!

Have a great day!

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

  • Posts: 56
  • Thank you received: 1
5 years 10 months ago #293281

Hi Nicolas,

I've made the modifications to invoice file and to administrator/components/com_hikashop/views/order/view.html.php, but when I add the second parameter true to loadFullOrder method in invoice page inside the product lists i see these 2 error (I have PHP error reporting ON):

Notice: Undefined variable: config in /home/siti/www.sushitalia.com/sushitalia.com/htdocs/administrator/templates/isis/html/com_hikashop/order/invoice.php on line 170

Fatal error: Call to a member function get() on null in /home/siti/www.sushitalia.com/sushitalia.com/htdocs/administrator/templates/isis/html/com_hikashop/order/invoice.php on line 170


I have HikaShop 3.4.0 on Joomla 3.8.3

What is the problem ?

Many thanks

Last edit: 5 years 10 months ago by trik84.

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

  • Posts: 12953
  • Thank you received: 1778
5 years 10 months ago #293297

Hello,

In that case, you should probably add that line :

$config = hikashop_config();
just before :
$imageHelper = hikashop_get('helper.image');

And it should do the job.

Best regards,
Mohamed Thelji.

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

  • Posts: 56
  • Thank you received: 1
5 years 10 months ago #293323

Hi Mohamed,

right, it works now !!!

Many Thanks

The following user(s) said Thank You: Philip

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

  • Posts: 356
  • Thank you received: 7
  • Hikashop Business
1 year 8 months ago #343634

Hi,

I have used this code in the attach invoice plugin to successfully get the product images in the pdf invoice. It all worked fine, but then over the weekend, I started to receive this error:

An error has occurred.

2 Unable to get the size of the image

I'm not sure why this is the case? The URL path to the image is correct and works fine. Do you have any ideas please?

This is for EVERY image on any order. This isn't any particular image.

Last edit: 1 year 8 months ago by grayt7.

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

  • Posts: 4519
  • Thank you received: 611
  • MODERATOR
1 year 8 months ago #343637

Hello,

We will need more elements to better progress on your subject, can you provide these elements :
- Error screenshot WITH the Joomla Debug activated (and in maximum level)
- Did you do an update a week ago (HikaShop or else)?
- OR even a customization of the attach invoice plugin code?
=> A test can be useful, process a try with the attach invoice unpublished, then you can see the result in Backend order form listing and by clicking the button invoice to have a preview.

Awaiting your precise returns to be able to progress on your subject.
Regards

Last edit: 1 year 8 months ago by Philip.

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

  • Posts: 356
  • Thank you received: 7
  • Hikashop Business
1 year 8 months ago #343658

hi,

The edited file:

public_html/plugins/hikashop/attachinvoice/attachinvoice/invoice.php

With the attached code (image)

The error is also attached with debug etc turned on.

Yes removing the code makes the invoice work.

Hope you can help,

Many thanks

Attachments:

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
1 year 8 months ago #343664

Hi,

This error indicates that the image file is not found.
Can you confirm that the file is at the place the system is looking at ?
As you hide the beginning of the paths in your screenshot, I can't say for sure but it seems that it's missing the "public_html" part in the path of the image.
So you probably need to modify $newURL to prepent that folder to it or even prepend the URL of the website so that it uses a full URL and not a local relative path.

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

Time to create page: 0.138 seconds
Powered by Kunena Forum