Jump to content

Invoice PDF file not showing the main/cover image


Jolsvi

Recommended Posts

Hi,

I'm pretty new in Prestashop. So I'm using Prestashop 1.6.1.4 and I found the issue with the order invoice generator.

So, I set my product with the combinations option. In the product page in front end, it shows the correct image ( for quantity 1 I set image with 1 product in it as cover, for quantity 2 I set image with 2 product in it as cover etc.. )

But when I receive the invoice, it is showing other image which is not as the main/cover.

Does anyone have the same experience and please help me to solve this issue.

Link to comment
Share on other sites

On 5/8/2020 at 4:56 PM, ndiaga said:

Hi,

It  depends  of  the  product  combination  you  ordered. 

Of   course  you  will have  the  combination  image  instead  of  the  default  cover  image.

Yes,

I have choosen the images for combination, like example :

- images that showing only 1 product are set for 1 bulk quantity

- images that showing only 2 products are set for 2 bulk quantity

But still, the pdf is showing the wrong image

 

Here is the image reference code that i found in the classes/pdf/HTMLTemplateInvoice.php :

if (Configuration::get('PS_PDF_IMG_INVOICE')) {
            foreach ($order_details as &$order_detail) {
                if ($order_detail['image'] != null) {
                    $name = 'product_mini_'.(int)$order_detail['product_id'].(isset($order_detail['product_attribute_id']) ? '_'.(int)$order_detail['product_attribute_id'] : '').'.jpg';
                    $path = _PS_PROD_IMG_DIR_.$order_detail['image']->getExistingImgPath().'.jpg';

                    $order_detail['image_tag'] = preg_replace(
                        '/\.*'.preg_quote(__PS_BASE_URI__, '/').'/',
                        _PS_ROOT_DIR_.DIRECTORY_SEPARATOR,
                        ImageManager::thumbnail($path, $name, 45, 'jpg', false),
                        1
                    );

                    if (file_exists(_PS_TMP_IMG_DIR_.$name)) {
                        $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_.$name);
                    } else {
                        $order_detail['image_size'] = false;
                    }
                }
            }
            unset($order_detail); // don't overwrite the last order_detail later
        }

 

And this is the template that i found in pdf/invoice.product-tab.tpl :

<td class="product center">
                {$order_detail.product_reference}
            </td>
            <td class="product left">
                {if $display_product_images}
                    <table width="100%">
                        <tr>
                            <td width="15%">
                                {if isset($order_detail.image) && $order_detail.image->id}
                                    {$order_detail.image_tag}
                                {/if}
                            </td>
                            <td width="5%">&nbsp;</td>
                            <td width="80%">
                                {$order_detail.product_name}
                            </td>
                        </tr>
                    </table>
                {else}
                    {$order_detail.product_name}
                {/if}

            </td>

 

 

missmatch images.jpg

Link to comment
Share on other sites

17 hours ago, ndiaga said:

Hi,

So  correct   it  by calling   the  right  image,  the  one   that  the  combination  uses.

Hi Ndiaga,

Thanks for your reply. Do you know how to call the right image by coding or any other alternatives?

Sorry, i'm really beginner about this

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...