Jump to content
Sign in to follow this  
spottedhaggis

Admin Image on Invoice

Recommended Posts

Hi all.

 

I have installed the contrib - Admin - Image on invoice

 

located here - http://www.oscommerce.com/community/contri...mage+on+invoice

 

For some reason I am just not able to get the image to display, the placeholder is there, it simply looks like the image is not located in the directory of the system, when I know for sure it is there.

 

Can anyone help me out with this.

 

The following is the contribution information, save you having to download it all.

 

ell I finally got some time to fiddle with this - and have a working solution now. Its not that elegant but it works for me. Anyone wanting to suggest a better way to do then please post. I use this with the 'actual attribute price' contrib (v 1.3) so my code will have extra info regarding attributes - but you should get this to work even if you havent that mod installed.

 

Just needs a minor change in admin/includes/classes/order.php

 

search for:

 

$orders_products_query = tep_db_query("select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");

while ($orders_products = tep_db_fetch_array($orders_products_query)) {

$this->products[$index] = array('qty' => $orders_products['products_quantity'],

'name' => $orders_products['products_name'],

'model' => $orders_products['products_model'],

'tax' => $orders_products['products_tax'],

'price' => $orders_products['products_price'],

'final_price' => $orders_products['final_price']);

 

Add an extra item in here - ive called it prod_id and also add it to the select statement

 

// admin image on invoice v1.1

$orders_products_query = tep_db_query("select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");

while ($orders_products = tep_db_fetch_array($orders_products_query)) {

$this->products[$index] = array('qty' => $orders_products['products_quantity'],

'name' => $orders_products['products_name'],

'model' => $orders_products['products_model'],

'tax' => $orders_products['products_tax'],

'prod_id' => $orders_products['products_id'],

'price' => $orders_products['products_price'],

'final_price' => $orders_products['final_price']);

// admin image on invoice v1.1 end

-------------------------------

end of changes to oder.php

---------------------------------

 

Then change the admin/invoice.php in two places.

The first change will find the image info based on the array of product_id's - works for multiple items in your invoice.

search for:

 

echo ' </td>' . "\n" .

' <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n";

echo ' <td class="dataTableContent" align="right" valign="top">' . tep_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" .

' <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .

 

then add directly BEFORE

 

// admin image on invoice v1.1

$prodimage_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$order->products[$i]['prod_id'] . "'");

$prodimage = tep_db_fetch_array($prodimage_query);

// mbr image on invoice v1.0 end

 

 

The second place is to actually show the images on the invoice

search for:

<td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";

echo ' </tr>' . "\n";

 

then add directly under this:

 

// admin image on invoice v1.1

echo ' <tr><td align="left" colspan="8" class="dataTableContent" valign="top">

' . tep_image('../' . DIR_WS_IMAGES . $prodimage['products_image'], $order->products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '</td></tr>' . "\n";

// admin image on invoice v1.1 end

 

 

This should place an image (size set by small image size in admin) for each item in your order. Probably not good code to do tep_image('../' . DIR_WS_IMAGES.. but i couldnt figure out how to get round this.

 

If you want a larger image - ie the original image size then change the last section to:

 

// admin image on invoice v1.1

echo ' <tr><td align="left" colspan="8" class="dataTableContent" valign="top">

' . tep_image('../' . DIR_WS_IMAGES . $prodimage['products_image'], $order->products[$i]['name']) . '</td></tr>' . "\n";

// admin image on invoice v1.1 end


Born - Scotland

Location - Kent, England

Job - hunting for one

Share this post


Link to post
Share on other sites

I have just come across this contrib and trying to get it working on 2.2 but having problems with the code, has anyone used this or something similar on more recent versions of osc?

 

Currently i get as far as "echo ' <tr><td align="left" colspan="8" class="dataTableContent" valign="top">" on the invoice.php amendment then my php editor starts going a little crazy on syntax errors.

Looking at the sections to what to edit and where this is obviously based on an old version of osc.

 

anyone got a better/newer/working version?

Share this post


Link to post
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
Sign in to follow this  

×