Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding images to invoices


maniac101

Recommended Posts

Posted

Hi,

 

i am needing to add a product image to the invoices generated by Oscommerce. I need to use this as a 'pick list' for when products get shipped - the physical shop doesnt have a computer or internet access, so its hard to just check what a product looked like and we need an image for each item. Sometimes the stock does not have any tags or labels on it to know if it is the right thing... i cant be the only one in this situation :-)

 

Ive looked through all the contribs but cannot find anything that does this - all of the updated invoice contribs are okay but they add no images.

 

I have had a look at the admin/invoices.php and have found out how to add to the right place when having multiple items etc.

 

ive looked in classes/orders.php - but there is no query that brings back the product image - so i was wondering how do i access the product image info from admin/invoices.php in the easiest manner ?

 

Ive looked at product info and also admin/catagories.php but am not sure exactly what bit of code to use - or wether i should do something with the orders table instead to have that contain a link to the image instead (if that is possible).

 

Any help with this would be greatly appreciated.

 

Regards

mark

Regards

Mark Brindle

  • 4 weeks later...
Posted

Well 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

// mbr image on invoice mod
 $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']);

 

Then change the admin/invoice.php in two places

search for:

    if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
       for ($j = 0; $j < $k; $j++) {

then add directly under the {

// mbr image on invoice mod
$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 mod 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:

// mbr image on invoice mod
  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";
// mbr image on invoice mod 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.

Regards

Mark Brindle

Posted

This is now in the contributions section. Contrib number 2904. Admin Image on Invoice.

Regards

Mark Brindle

  • 3 years later...
Posted

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?

Posted

I don't use one for the invoice,but a good one for adding pictures to the packing slip is :Packing Slip with Pictures –Contribution 2156

Hope it helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...