product image on invoice

Phoca Cart - complex e-commerce extension
jpeters
Phoca Professional
Phoca Professional
Posts: 225
Joined: 31 Dec 2020, 09:46

product image on invoice

Post by jpeters »

Hello Phoca lovers..
i would like to have a product image on the invoice / order / etc..
like the shopping cart.. when i add a product the main product image (or the image if product is a attribute).
how can i do that if possible..
i have read the template override, but i am not as good in programming that i know how to add the right image.
ofcourse the images in small size on the invoice..

thanks

Tags:
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: product image on invoice

Post by Jan »

Hi, yes, the template override is the solution:

components\com_phocacart\layouts\order.php

line cca 606 - the table for product items starts
line cca 634 - the row for product starts

Images are not stored in orders so you need to get images from product table, for example:

Code: Select all

$product 		= PhocacartProduct::getProduct($v->product_id);
		$path			= PhocacartPath::getPath('productimage');// this can be moved before foreach (to save resources)
		$productImage 	= PhocacartImage::getThumbnailName($path, $product->image, 'small');
		$productImageOutput = '<img src="'.JURI::root().''.$productImage->rel.'" alt="" />';
then you all the image tag is stored in $productImageOutput

BTW: the function PhocacartProduct::getProduct($v->product_id); is performance intensive so I will add some simple function to version 3.5.5 to get the image faster: PhocacartProduct::getImagesByProductId($v->product_id);

Code: Select all

$productImageOutput = '';
$productImage 		= PhocacartProduct::getImageByProductId($v->product_id);
		$path				= PhocacartPath::getPath('productimage');// add before foreach
		if ($productImage != '') {
			$productThumbnail 	= PhocacartImage::getThumbnailName($path, $productImage, 'small');
			$productImageOutput = '<img src="'.JURI::root().''.$productThumbnail->rel.'" alt="" />';
		}
Jan
If you find Phoca extensions useful, please support the project
jpeters
Phoca Professional
Phoca Professional
Posts: 225
Joined: 31 Dec 2020, 09:46

Re: product image on invoice

Post by jpeters »

Hello, thanks for your response.. i will try to get this to work..
idea to promote this toppic to feature request.. so inside options you have a setting product image on invoice yes/no
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: product image on invoice

Post by Jan »

Hi, added to feature request list.

And of course it is a little bit problematic feature.

- Invoice is an accounting document where images should not be displayed. Accounting does not need images. Images occupy place for another items. In fact, you need to have as short document as possible. Accounting document should not includes parts which just move important data to other pages and make such document larger.

It just takes place in both directions - in horizonal and vertical which is needed for important data.

- Order does not include information about image, so it needs to get this info from product table - which means more memory and cpu usage when creating invoice (when we are talking about PDF invoices, this feature needs free resources as much as possible - dispaying images in large PDF document can be problematic).

- Possible problems when formatting documents.

Images should be displayed for customer acquisition and not for tax and accounting audits. :-)

Jan
If you find Phoca extensions useful, please support the project
Post Reply