komodityagro Posted August 19, 2013 Share Posted August 19, 2013 How can I add supplier name to PDF document delivery slip? Link to comment Share on other sites More sharing options...
swsindonesia Posted August 19, 2013 Share Posted August 19, 2013 Hi, you can start by editing the template file in: pdf/invoice.tpl Link to comment Share on other sites More sharing options...
komodityagro Posted August 19, 2013 Author Share Posted August 19, 2013 Hi swsindonesia, thanks for reply, but I want to add supplier name to delivery-slip.tpl. Link to comment Share on other sites More sharing options...
swsindonesia Posted August 19, 2013 Share Posted August 19, 2013 oops, sorry for the misread. Unfortunately supplier_name is not assigned by default by PS in delivery-slip.tpl, it only has the default id_supplier variable. which means you have to go further deep than the tpl file. Another way without touching any code is to use a supplier reference. Let say you have a supplier name: Acme, INC. 1. You set the supplier to your product, by editing it. 2. Manually add again, "Acme, INC" to the supplier reference field 3. the supplier reference will be displayed in your delivery slip If you think this solution is way too tedious or you have like 1000+ products and supplier, then you need to start thinking about touching the code is AdminPdf / Order / Product Link to comment Share on other sites More sharing options...
komodityagro Posted August 19, 2013 Author Share Posted August 19, 2013 thanks, but Supplier reference I can see only in the Order but in Delivery slip.PDF document I can´t see Link to comment Share on other sites More sharing options...
swsindonesia Posted August 19, 2013 Share Posted August 19, 2013 (edited) Shoot.... You're right, you can't have any other information than id_supplier in your delivery.. terribly sorry for misleading. Ok, looks like we have to go deeper into the rabbit hole.. here goes.. 1. Copy classes/order/OrderInvoice.php to override/classes/order/OrderInvoice.php 2. Edit the copied file (this is a very excellent way of hacking into PS, without breaking it apart) go to line around 165, after $row['id_address_delivery'] = $order->id_address_delivery; add: $row['id_address_delivery'] = $order->id_address_delivery; $row['supplier_name'] = Supplier::getNameById($row['id_supplier']); this will get supplier name for your product 3. Open pdf/delivery-slip.tpl look for the product foreach loop, and add the supplier name -> {$product.supplier_name} {foreach $order_details as $product} {cycle values='#FFF,#DDD' assign=bgcolor} <tr style="line-height:6px;background-color:{$bgcolor};"> <td style="text-align: left; width: 60%">{$product.product_name} supplier: {$product.supplier_name} </td> IMPORTANT: DELETE cache/class_index.php otherwise you'll be pulling your hair off. also.. don't forget to set the supplier reference for your product 100% tested and worked using PS 1.5.4.1 Have fun, tell me if it works on your side and click "like this" Edited August 19, 2013 by swsindonesia (see edit history) 1 Link to comment Share on other sites More sharing options...
komodityagro Posted August 19, 2013 Author Share Posted August 19, 2013 Thanks, it works perfect... but is possible also add supplier address, phone and e-mail? Link to comment Share on other sites More sharing options...
swsindonesia Posted August 20, 2013 Share Posted August 20, 2013 (edited) Thanks, it works perfect... but is possible also add supplier address, phone and e-mail? Glad that works well on your side, please take time to edit this topic as [sOLVED] to add more details of your supplier, just query from the Address object, add these code after the modification in OrderInvoice.php $row['supplier_name'] = Supplier::getNameById($row['id_supplier']); // get more details $id_address = Address::getAddressIdBySupplierId($row['id_supplier']); $supplier_address_object = Address::initialize($id_address); $row['supplier_address1'] = $supplier_address_object->address1; $row['supplier_address2'] = $supplier_address_object->address2; $row['supplier_postcode'] = $supplier_address_object->postcode; $row['supplier_city'] = $supplier_address_object->city; $row['supplier_phone'] = $supplier_address_object->phone; $row['supplier_phone_mobile'] = $supplier_address_object->phone_mobile; then as you can guess, you can use any variables available there in your tpl such as $product.supplier_address1, $product.supplier_phone, and so on respectively. You can find more info about this by looking at your database table: ps_address select * from ps_address where alias='supplier' cheers. Edited August 20, 2013 by swsindonesia (see edit history) 1 Link to comment Share on other sites More sharing options...
coolpapes Posted March 5, 2014 Share Posted March 5, 2014 Shoot.... You're right, you can't have any other information than id_supplier in your delivery.. terribly sorry for misleading. Ok, looks like we have to go deeper into the rabbit hole.. here goes.. 1. Copy classes/order/OrderInvoice.php to override/classes/order/OrderInvoice.php 2. Edit the copied file (this is a very excellent way of hacking into PS, without breaking it apart) go to line around 165, after $row['id_address_delivery'] = $order->id_address_delivery; add: $row['id_address_delivery'] = $order->id_address_delivery; $row['supplier_name'] = Supplier::getNameById($row['id_supplier']); this will get supplier name for your product 3. Open pdf/delivery-slip.tpl look for the product foreach loop, and add the supplier name -> {$product.supplier_name} {foreach $order_details as $product} {cycle values='#FFF,#DDD' assign=bgcolor} <tr style="line-height:6px;background-color:{$bgcolor};"> <td style="text-align: left; width: 60%">{$product.product_name} supplier: {$product.supplier_name} </td> IMPORTANT: DELETE cache/class_index.php otherwise you'll be pulling your hair off.also.. don't forget to set the supplier reference for your product 100% tested and worked using PS 1.5.4.1 Have fun, tell me if it works on your side and click "like this" How can I add the supplier reference? Link to comment Share on other sites More sharing options...
tuk66 Posted March 6, 2014 Share Posted March 6, 2014 Do you mean supplier ID? Link to comment Share on other sites More sharing options...
alpe09ag Posted May 5, 2014 Share Posted May 5, 2014 Shoot.... You're right, you can't have any other information than id_supplier in your delivery.. terribly sorry for misleading. Ok, looks like we have to go deeper into the rabbit hole.. here goes.. 1. Copy classes/order/OrderInvoice.php to override/classes/order/OrderInvoice.php 2. Edit the copied file (this is a very excellent way of hacking into PS, without breaking it apart) go to line around 165, after $row['id_address_delivery'] = $order->id_address_delivery; add: $row['id_address_delivery'] = $order->id_address_delivery; $row['supplier_name'] = Supplier::getNameById($row['id_supplier']); this will get supplier name for your product 3. Open pdf/delivery-slip.tpl look for the product foreach loop, and add the supplier name -> {$product.supplier_name} {foreach $order_details as $product} {cycle values='#FFF,#DDD' assign=bgcolor} <tr style="line-height:6px;background-color:{$bgcolor};"> <td style="text-align: left; width: 60%">{$product.product_name} supplier: {$product.supplier_name} </td> IMPORTANT: DELETE cache/class_index.php otherwise you'll be pulling your hair off.also.. don't forget to set the supplier reference for your product 100% tested and worked using PS 1.5.4.1 Have fun, tell me if it works on your side and click "like this" Hi, would this be possible to to with manufacture name ? Link to comment Share on other sites More sharing options...
rolandsblujus Posted May 14, 2015 Share Posted May 14, 2015 Glad that works well on your side, please take time to edit this topic as [sOLVED] to add more details of your supplier, just query from the Address object, add these code after the modification in OrderInvoice.php $row['supplier_name'] = Supplier::getNameById($row['id_supplier']); // get more details $id_address = Address::getAddressIdBySupplierId($row['id_supplier']); $supplier_address_object = Address::initialize($id_address); $row['supplier_address1'] = $supplier_address_object->address1; $row['supplier_address2'] = $supplier_address_object->address2; $row['supplier_postcode'] = $supplier_address_object->postcode; $row['supplier_city'] = $supplier_address_object->city; $row['supplier_phone'] = $supplier_address_object->phone; $row['supplier_phone_mobile'] = $supplier_address_object->phone_mobile; then as you can guess, you can use any variables available there in your tpl such as $product.supplier_address1, $product.supplier_phone, and so on respectively.You can find more info about this by looking at your database table: ps_address select * from ps_address where alias='supplier' cheers. Great.. This works also on Prestashop 1.6 Is it possible to add also supplier description? I have tried add my own custom code in controller, but without luck. Link to comment Share on other sites More sharing options...
Recommended Posts