mytwocentimes Posted November 15, 2012 Share Posted November 15, 2012 I'm looking to understand IN GENERAL how to put various database variables into PDFs like Delivery Slips or Invoices. **OR** How do I replace the REFERENCE variable in the delivery slip with the WAREHOUSE LOCATION variable ? thanks in advance D 1 Link to comment Share on other sites More sharing options...
mytwocentimes Posted November 15, 2012 Author Share Posted November 15, 2012 I'm looking to understand IN GENERAL how to put various database variables into PDFs like Delivery Slips or Invoices. **OR** How do I replace the REFERENCE variable in the delivery slip with the WAREHOUSE LOCATION variable ? I guess what I'm looking for is the *name* of the class / object / variable / whatever that contains a product's WAREHOUSE LOCATION thanks Link to comment Share on other sites More sharing options...
mytwocentimes Posted November 15, 2012 Author Share Posted November 15, 2012 I guess what I'm looking for is the *name* of the class / object / variable / whatever that contains a product's WAREHOUSE LOCATION OK - I'm getting closer. I've found the DATABASE TABLE "ps_warehouse_product_location" and the FIELDS id_warehouse_product_location id_product id_product_attribute id_warehouse location So my question is ... how do I get the "location" field into the Delivery Slip PDF ... thanks in advance Link to comment Share on other sites More sharing options...
carelessoul Posted December 17, 2012 Share Posted December 17, 2012 I'm having a similar problem and I would like to ask if you've found a solution for this? Link to comment Share on other sites More sharing options...
emericd Posted January 8, 2013 Share Posted January 8, 2013 Hello, I recommand module M4 PDF extensions that can do this. The template with product location is available. Regards Link to comment Share on other sites More sharing options...
mizou125 Posted March 13, 2013 Share Posted March 13, 2013 any solution for PS 1.5 ??? Link to comment Share on other sites More sharing options...
bloggus Posted March 13, 2013 Share Posted March 13, 2013 Is there any way to put in the location of the product in the warehouse, like a shelf number? There is no such field anymore or? 1 Link to comment Share on other sites More sharing options...
ludivick Posted June 22, 2013 Share Posted June 22, 2013 I am also looking for this.... Link to comment Share on other sites More sharing options...
mytwocentimes Posted July 23, 2013 Author Share Posted July 23, 2013 8 months later and I'm still looking for a solution to using the ps_warehouse_product_location.location field in a Delivery Slip. Soon - I should upgrade to a current version of Prestashop ... but that may wait till Christmas Link to comment Share on other sites More sharing options...
PhpMadman Posted October 2, 2013 Share Posted October 2, 2013 Using 1.5.5.0 as test, I got it working. Edit classes/pdf/HTMLTemplateDeliverySlip.php On line 70: 'order_details' => $this->order_invoice->getProducts(), change to 'order_details' => $order_details, Around line 65 (above this line $carrier = new Carrier($this->order->id_carrier);) Add this code: $order_details = $this->order_invoice->getProducts(); foreach ($order_details as $key => $order_detail) { $order_details[$key]['warehouse_name'] = "--"; $order_details[$key]['warehouse_location'] = "--"; if ($order_detail['id_warehouse'] != 0) { $warehouse = new Warehouse((int)$order_detail['id_warehouse']); $warehouse_location = $warehouse->getProductLocation($order_detail["product_id"],$order_detail["product_attribute_id"],$warehouse->id); $order_details[$key]['warehouse_name'] = $warehouse->name; $order_details[$key]['warehouse_location'] = $warehouse_location; } } Then you can use $product.warehouse_name and $product.warehouse_location in the pdf/delivery-slip.tpl 3 Link to comment Share on other sites More sharing options...
coolpapes Posted December 5, 2013 Share Posted December 5, 2013 Using 1.5.5.0 as test, I got it working. Edit classes/pdf/HTMLTemplateDeliverySlip.php On line 70: 'order_details' => $this->order_invoice->getProducts(), change to 'order_details' => $order_details, Around line 65 (above this line $carrier = new Carrier($this->order->id_carrier);) Add this code: $order_details = $this->order_invoice->getProducts(); foreach ($order_details as $key => $order_detail) { $order_details[$key]['warehouse_name'] = "--"; $order_details[$key]['warehouse_location'] = "--"; if ($order_detail['id_warehouse'] != 0) { $warehouse = new Warehouse((int)$order_detail['id_warehouse']); $warehouse_location = $warehouse->getProductLocation($order_detail["product_id"],$order_detail["product_attribute_id"],$warehouse->id); $order_details[$key]['warehouse_name'] = $warehouse->name; $order_details[$key]['warehouse_location'] = $warehouse_location; } } Then you can use $product.warehouse_name and $product.warehouse_location in the pdf/delivery-slip.tpl How do I get the location to display? Link to comment Share on other sites More sharing options...
PhpMadman Posted December 5, 2013 Share Posted December 5, 2013 I explained it my post. Modify the file as I wrote and then in the pdf/delivery-slip.tpl you use $product.warehouse_location or $product.warehouse_name where ever you see fit. Link to comment Share on other sites More sharing options...
tuk66 Posted December 6, 2013 Share Posted December 6, 2013 {$product.warehouse_location} and/or {$product.warehouse_name} in /pdf/delivery-slip.tpl template Link to comment Share on other sites More sharing options...
GaTo Posted March 10, 2014 Share Posted March 10, 2014 Using 1.5.5.0 as test, I got it working. Edit classes/pdf/HTMLTemplateDeliverySlip.php On line 70: 'order_details' => $this->order_invoice->getProducts(), change to 'order_details' => $order_details, Around line 65 (above this line $carrier = new Carrier($this->order->id_carrier);) Add this code: $order_details = $this->order_invoice->getProducts(); foreach ($order_details as $key => $order_detail) { $order_details[$key]['warehouse_name'] = "--"; $order_details[$key]['warehouse_location'] = "--"; if ($order_detail['id_warehouse'] != 0) { $warehouse = new Warehouse((int)$order_detail['id_warehouse']); $warehouse_location = $warehouse->getProductLocation($order_detail["product_id"],$order_detail["product_attribute_id"],$warehouse->id); $order_details[$key]['warehouse_name'] = $warehouse->name; $order_details[$key]['warehouse_location'] = $warehouse_location; } } Then you can use $product.warehouse_name and $product.warehouse_location in the pdf/delivery-slip.tpl Thanks! Perfect :) Link to comment Share on other sites More sharing options...
Ledfanatic Posted May 29, 2014 Share Posted May 29, 2014 Thank you men I got it for the delivery_slip pdf and it really help me. And now, how is it possible to make the same thing in the order details view ? Thank's Link to comment Share on other sites More sharing options...
PhpMadman Posted May 29, 2014 Share Posted May 29, 2014 Order details view? I don't understand, where exactly do you want it? Link to comment Share on other sites More sharing options...
Ledfanatic Posted May 31, 2014 Share Posted May 31, 2014 Hi, In fact I want it in the product table of the order detail view...not sure for the english terms So a pictures is better than words I would like to see warehouse.location where I have highlighted in yellow Thank you Link to comment Share on other sites More sharing options...
PhpMadman Posted May 31, 2014 Share Posted May 31, 2014 (edited) Okey, so in the product line, on admin order view. Linenumbers are from 1.5.6.2Step 1/controllers/admin/AdminOrdersController.php if ($product['id_warehouse'] != 0) { $warehouse = new Warehouse((int)$product['id_warehouse']); $product['warehouse_name'] = $warehouse->name; /* Delivery location patch*/ $warehouse_location = $warehouse->getProductLocation($product["product_id"],$product["product_attribute_id"],$warehouse->id); $product['warehouse_location'] = $warehouse_location; /* Delivery location patch*/ } else $product['warehouse_name'] = '--'; Step 2/admin/themes/default/template/controllers/orders/_product_line.tplWe must replace this line {if $display_warehouse}<td align="center">{$product.warehouse_name|escape:'htmlall':'UTF-8'}</td>{/if} With this slightly modified code {if $display_warehouse}<td align="center">{$product.warehouse_name|escape:'htmlall':'UTF-8'} <br>{$product.warehouse_location|escape:'htmlall':'UTF-8'} </td>{/if} This will place warehouse location bellow the warehouse name, in the warehouse column. Edited May 31, 2014 by PhpMadman (see edit history) 3 Link to comment Share on other sites More sharing options...
Ledfanatic Posted June 1, 2014 Share Posted June 1, 2014 Hi PhpMadman, Very nice of you !! It works like a charm I want to thank you for that because I never found the solution on the french prestashop Forum and you give me two in just a minute or so Your help is much appreciated Link to comment Share on other sites More sharing options...
mcbain.neil Posted June 30, 2014 Share Posted June 30, 2014 The solution by Prestashop Apprentice uses the warehouse location field from the BO/Catalogue./Products/Warehouse/Location field - I need to get the warehouse location from the BO/Stock/Warehouses/Location field. Anyone tried this? Link to comment Share on other sites More sharing options...
JuanjoSC Posted August 16, 2014 Share Posted August 16, 2014 (edited) PhpMadman. I also need to see the location in "order detail" but in version 1.6 I tried it your solution but does not work for me. EDIT: It only works with orders created after putting the location. Is it possible to read the value of table [prefix] _warehouse_product_location the product and not the order? Can you help me? Thanks! Edited August 16, 2014 by JuanjoSC (see edit history) Link to comment Share on other sites More sharing options...
mattheoh Posted March 31, 2015 Share Posted March 31, 2015 (edited) Hi, i m following this post cause I m trying to add the warehouse location in the invoice pdf. (Prestahsop 1.6.0.14) I made the following override : /override/classes/pdf/HTMLTemplateInvoice.php containing (following @PhpMadman's post) <?php class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore { public function getContent() { $invoice_address = new Address((int)$this->order->id_address_invoice); $country = new Country((int)$invoice_address->id_country); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int)$this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int)$this->order->id_customer); $order_details = $this->order_invoice->getProducts(); foreach ($order_details as $key => $order_detail) { $order_details[$key]['warehouse_name'] = "--"; $order_details[$key]['warehouse_location'] = "--"; if ($order_detail['id_warehouse'] != 0) { $warehouse = new Warehouse((int)$order_detail['id_warehouse']); $warehouse_location = $warehouse->getProductLocation($order_detail["product_id"],$order_detail["product_attribute_id"],$warehouse->id); $order_details[$key]['warehouse_name'] = $warehouse->name; $order_details[$key]['warehouse_location'] = $warehouse_location; } } 'order_details' => $order_details, 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'; $order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$order_detail['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg', false); if (file_exists(_PS_TMP_IMG_DIR_.$name)) $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_.$name); else $order_detail['image_size'] = false; } } $data = array( 'order' => $this->order, 'order_details' => $order_details, 'cart_rules' => $this->order->getCartRules($this->order_invoice->id), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer ); if (Tools::getValue('debug')) die(json_encode($data)); $this->smarty->assign($data); return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); } } I added the code from line 21 to 33. and changed the line 35. But it doesn't work. Someone would have an idea about what I made wrong ? Thanks per advance to anyone who can help. Edited March 31, 2015 by mattheoh (see edit history) 1 Link to comment Share on other sites More sharing options...
tuk66 Posted April 1, 2015 Share Posted April 1, 2015 Slightly different solution could be {$order[orders].order_detail[detail].warehouse_product_location.location|escape:'htmlall':'UTF-8'} Used in m4_deliveryslip_image.tpl and m4_invoice_label2.tpl templates (M4 PDF Extensions), out of the box. Link to comment Share on other sites More sharing options...
mattheoh Posted April 1, 2015 Share Posted April 1, 2015 Slightly different solution could be {$order[orders].order_detail[detail].warehouse_product_location.location|escape:'htmlall':'UTF-8'} Used in m4_deliveryslip_image.tpl and m4_invoice_label2.tpl templates (M4 PDF Extensions), out of the box. Thanks for the answer. But something is missing. When I add this code in the invoice.tpl, it breaks the generation (no more pdf to download, just few html information displayed in the browser) Link to comment Share on other sites More sharing options...
tuk66 Posted April 1, 2015 Share Posted April 1, 2015 I mentioned that this is a different solution used by the M4 PDF Extensions module. It doesn't work in the original invoice.tpl template. Link to comment Share on other sites More sharing options...
mattheoh Posted April 1, 2015 Share Posted April 1, 2015 I mentioned that this is a different solution used by the M4 PDF Extensions module. It doesn't work in the original invoice.tpl template. Teaser !!! Link to comment Share on other sites More sharing options...
losdelsolo Posted April 2, 2015 Share Posted April 2, 2015 (edited) Hi to all, I just find this deliveryslip tweak for the warehouse location echo in it, it's really useful ! Thanks to Madman for his code. I try to do the same with the invoice because we work mainly without delivery slip and i m on the same situation as mattheoh.. I have checked the code for invoice implant and i can't find a clean solution but i m sure there is small modification to do only but where ? If someone or Madman can helps us about this it should be really useful for the community ! So, please oh great php master help us to display the {$product.warehouse_location} variable content correcly in the invoice :-) Wish you an Happy coding and Debugging :-) Best regards, Sam Edited April 2, 2015 by losdelsolo (see edit history) 1 Link to comment Share on other sites More sharing options...
PhpMadman Posted April 7, 2015 Share Posted April 7, 2015 Hi. I haven't been following this thread, but, I do now.Anyway, there are several people asking for adding in to invoice as well. Using this code from my post Same code goes in both classes/pdf/HTMLTemplateDeliverySlip.php and classes/pdf/HTMLTemplateInvoice.php In delivery-slip.tpl, you should use $product.warehouse_name and $product.warehouse_locationIn invoice.tpl, ps changed the syntax, and there it is $order_detail instead. $order_detail.warehouse_name and $order_detail.warehouse_location I havent tested any of this. But it should work. Adding it to orderSlip is a bit more complex. You can just use $order_details, instead, there already is a foreach $this->products, there you have to add the warehouse_*, and it's also another syntax within the php file, and you also have to change the syntax of the foreach.the tpl file use $order_detail. If anyone does want it on orderSlip, i'll help if needed. Link to comment Share on other sites More sharing options...
mattheoh Posted April 7, 2015 Share Posted April 7, 2015 (edited) Hi. Same code goes in both classes/pdf/HTMLTemplateDeliverySlip.php and classes/pdf/HTMLTemplateInvoice.php In delivery-slip.tpl, you should use $product.warehouse_name and $product.warehouse_location In invoice.tpl, ps changed the syntax, and there it is $order_detail instead. $order_detail.warehouse_name and $order_detail.warehouse_location I havent tested any of this. But it should work. Hi, and thanks for your feedback. I tried to override HTMLTemplateInvoice.php to add the location in the PDF invoices. I m on Prestashop 1.6.0.14 I added the override, of the function getContent(), but the code is a little bit different from TemplateDeliverySlip.php Here 's my override code : <?php class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore { public function getContent() { $invoice_address = new Address((int)$this->order->id_address_invoice); $country = new Country((int)$invoice_address->id_country); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $formatted_delivery_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $delivery_address = new Address((int)$this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); } $customer = new Customer((int)$this->order->id_customer); $order_details = $this->order_invoice->getProducts(); foreach ($order_details as $key => $order_detail) { $order_details[$key]['warehouse_name'] = "--"; $order_details[$key]['warehouse_location'] = "--"; if ($order_detail['id_warehouse'] != 0) { $warehouse = new Warehouse((int)$order_detail['id_warehouse']); $warehouse_location = $warehouse->getProductLocation($order_detail["product_id"],$order_detail["product_attribute_id"],$warehouse->id); $order_details[$key]['warehouse_name'] = $warehouse->name; $order_details[$key]['warehouse_location'] = $warehouse_location; } } 'order_details' => $order_details, 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'; $order_detail['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$order_detail['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg', false); if (file_exists(_PS_TMP_IMG_DIR_.$name)) $order_detail['image_size'] = getimagesize(_PS_TMP_IMG_DIR_.$name); else $order_detail['image_size'] = false; } } $data = array( 'order' => $this->order, 'order_details' => $order_details, 'cart_rules' => $this->order->getCartRules($this->order_invoice->id), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer ); if (Tools::getValue('debug')) die(json_encode($data)); $this->smarty->assign($data); return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); } } as I said in a previous post, I added your code from line 21 to 33. and changed the line 35. Then as you said, I add $order_detail.warehouse_name in invoice.tpl, but doesn't seem to work. I think I don't modify correctly the function getContent() and specially the part concerning 'order_details' => $order_details (line 35). You can see this code also appears line 52 (don't know if it's important) Do you have an idea of my mistake ? Thanks a lot ! Edited April 7, 2015 by mattheoh (see edit history) Link to comment Share on other sites More sharing options...
PhpMadman Posted April 8, 2015 Share Posted April 8, 2015 Hi. If that simply does not show up in pdf, then the override is not working. And you need to delete the cache/class_index.php file. Beacuse, that code should crash the pdf. Line 35, should be removed, it's wrong and useless. Line 52, is the line that send's data to the tpl, so that's the most important one of all ; ) Other than that, it seems fine to me. Link to comment Share on other sites More sharing options...
mattheoh Posted April 8, 2015 Share Posted April 8, 2015 Hi and thanks for your answer ! If that simply does not show up in pdf, then the override is not working. And you need to delete the cache/class_index.php file. I m an idiot ! I forgot... Indeed now it's crashing ;-) Line 35, should be removed, it's wrong and useless. Line 52, is the line that send's data to the tpl, so that's the most important one of all ; ) Other than that, it seems fine to me. I deleted the line, but unfortunately, it doesn't seem to work. I checked an invoice, containing a product which has information in field "location" in ps_product table, but nothing shows up with $order_detail.warehouse_name or $order_detail.warehouse_location added in invoice.tpl. Thanks again for your help ! Link to comment Share on other sites More sharing options...
PhpMadman Posted April 8, 2015 Share Posted April 8, 2015 That's strange, at very least, it should show -- on all products. If you don't get that, then warehouse_* don't get added correctly. If you turn on Debug mode, the pdf should show either -- or undefinded index warehouse_* on each line. Link to comment Share on other sites More sharing options...
mattheoh Posted April 8, 2015 Share Posted April 8, 2015 (edited) That's strange, at very least, it should show -- on all products. If you don't get that, then warehouse_* don't get added correctly. If you turn on Debug mode, the pdf should show either -- or undefinded index warehouse_* on each line. It does ! (sorry didn't indicate that) without turning debug mode , indeed, it shows " -- " on all products lines. But no location name, on a product line whom has one in the database. (see screens attached) no more indication if I turn debug mode on . Thanks again for your help ! Edited April 8, 2015 by mattheoh (see edit history) Link to comment Share on other sites More sharing options...
losdelsolo Posted April 8, 2015 Share Posted April 8, 2015 (edited) For Matt, The location field in product_table is present but not used anymore by ps >1.5.6 For warehouse_location you have to use advanced stock management, define a warehouse, and in the product tab go to warehouse, put product in warehouse, define a rack/shelve location in the field location of the product warehouse tab.The warehouse_location values are read from ps_warehouse_product_location table not from the ps_product table. Hope this help, Regards, Sam PS: Madman, thanks a lot for your help about this tweak. Edited April 8, 2015 by losdelsolo (see edit history) 1 Link to comment Share on other sites More sharing options...
PhpMadman Posted April 8, 2015 Share Posted April 8, 2015 He is on 1.6.0.14. So expecting location from ps_product explains the problem. For this to work, you need to do as losdelsolo said. Set Warehouse and then set location there. 1 Link to comment Share on other sites More sharing options...
mattheoh Posted April 8, 2015 Share Posted April 8, 2015 You're both perfectly right ! My customer was adding the location with store commander, and indeed it was still inserted in the old field in ps_product table. So, I activated the advanced stock management, and fullfilled the informations. I updated one product to test : deleted cache/class_index.php , cache... and can't still see the location in the invoice ! the code in my invoice.tpl is the following one : <td style="text-align: left; width: 5%;">{$order_detail.warehouse_location}</td> I m sorry, just feel like a noob ! :-( Link to comment Share on other sites More sharing options...
PhpMadman Posted April 8, 2015 Share Posted April 8, 2015 That's very strange. I don't see anything wrong with your code. And if you updated a product and then places an order on that product, the warehouse should show up. I don't remember how PS collects the products for order_invoice, but it uses info from the order_details table, it might not show on old orders. I'll look in to that after work. 1 Link to comment Share on other sites More sharing options...
mattheoh Posted April 8, 2015 Share Posted April 8, 2015 (edited) That's very strange. I don't see anything wrong with your code. And if you updated a product and then places an order on that product, the warehouse should show up. I don't remember how PS collects the products for order_invoice, but it uses info from the order_details table, it might not show on old orders. I'll look in to that after work. That's what I did ... I updated the product #3260. And cause it wasn't working on an old invoice containing it, I tried to place a new order (was also thinking that the invoice could extract informations from ps_order_details table) but same result (it's the screenshot I did). Maybe it s my override which is not correct. Does it work on your installation, if you place it override/classes/pdf ? HTMLTemplateInvoice.php Edited April 8, 2015 by mattheoh (see edit history) Link to comment Share on other sites More sharing options...
losdelsolo Posted April 8, 2015 Share Posted April 8, 2015 Hi to all, I just implant the invoice warehouse product tweak in my ps 1.5.6.1 shop and everything is ok. Now the delivery slip and invoice contains the famous warehouse product location values :-) For mat, check your ps cache, your template compilation switch too, may be your trouble come from that because there is no trouble with this code on ps 1.5. Ca marche, yes !!! :-) Regards, Sam 1 Link to comment Share on other sites More sharing options...
PhpMadman Posted April 9, 2015 Share Posted April 9, 2015 (edited) Yes. It's worked directly and on old orders. I'm running 1.6.0.9 on my dev site. Havent upgraded yet. So, since you do get the --, but not the location, there must be something missing on the product. Is it checked as stored? Can you clear all cache? Do you cache pdf to the harddrive? I never used it, but I assume you need to delete the pdf file then, to get an real update. Also do Sam's suggestions. Edited April 9, 2015 by PhpMadman (see edit history) Link to comment Share on other sites More sharing options...
mattheoh Posted April 9, 2015 Share Posted April 9, 2015 (edited) I m becoming crazy... I clean all the caches, delete class_index.php, checked that the product was stored, tried to edit directly the files without overriding... Can I ask you a last favor PhpMadman ? on your 1.6.0.9, can you add the two files attached in your folders : themes/yourtheme/pdf/invoice.tpl (delete the .txt extensions) override/classes/pdf/HTMLInvoice.php (don't forget to use the original prestashop file in classes/pdf/ and not a modified one) and tell me if it's working. I just tried on a 1.6.0.11, and it's not working. If it's working for you, that means, it's not a problem from the code / files, but from my configuration. Thanks a lot to you both ! HTMLTemplateInvoice.php invoice.tpl.txt Edited April 9, 2015 by mattheoh (see edit history) Link to comment Share on other sites More sharing options...
PhpMadman Posted April 9, 2015 Share Posted April 9, 2015 Hi. I checked my real classes file, and it's original. Added you invoice.tpl to the bootstrap theme, re-uploaded the override. All is working fine. So, somewhere, your configuration is doing something it shouldn't.. Link to comment Share on other sites More sharing options...
mattheoh Posted April 9, 2015 Share Posted April 9, 2015 (edited) thanks a lot for the test and the confirmation. I found the reason reading the override code. In my ps_order_detail table, I have systematically id_warehouse = 0 , even on new orders. That's why have always in invoices : "--" Now, I have to understand why ! ^^ Thanks again for your big help PhpMadman and losdelsolo Edited April 9, 2015 by mattheoh (see edit history) Link to comment Share on other sites More sharing options...
PhpMadman Posted April 9, 2015 Share Posted April 9, 2015 0!? Check the warehouse table. Is your warehouse id 0?, because if it is, something is very very wrong. If id is 1 or higher as it should be, then there is a most likely a module running some code, that sets the warehouse to 0. Link to comment Share on other sites More sharing options...
mattheoh Posted April 9, 2015 Share Posted April 9, 2015 (edited) Yes 0 ! ;-) ps_order_detail : but the id_warehouse is at 1 in ps_warehouse : Now I have to find the guilty ! Maybe it could be store commander which wasn t set with advanced stock management... Do you confirm that it's not necessary to set advanced stock management for each product ? (it's sufficient to store a product in a warehouse and add the location) let's wait and see the next orders. Thanks again for your help ! Edited April 9, 2015 by mattheoh (see edit history) Link to comment Share on other sites More sharing options...
mattheoh Posted April 9, 2015 Share Posted April 9, 2015 (edited) Finally I got it ! It wasn't an incompatibilty with a module. I just had to check the advanced stock management in the product concerned I have to do a SQL query to do that on all my products. Merci , Merci beaucoup messieurs ;-) Edited April 9, 2015 by mattheoh (see edit history) Link to comment Share on other sites More sharing options...
losdelsolo Posted April 10, 2015 Share Posted April 10, 2015 For Mat, Mais de rien :-) You are welcome :-) Parfois on s'embarque dans des trucs pas possible alors que la solution est sous nos yeux, i know ! Regards, Sam 1 Link to comment Share on other sites More sharing options...
PhpMadman Posted April 10, 2015 Share Posted April 10, 2015 (edited) Nice. Glad it finally solved. I'm so used to Advanced stock, that I forget that you need to switch it on in each product when activating it for the first time. And due to the switches I added in an earlier version of PS (1.6.0.11 i think or as early as 1.6.0.4 and 1.6.0.6), I don't have bother to do that on new products. Edited April 10, 2015 by PhpMadman (see edit history) 1 Link to comment Share on other sites More sharing options...
Niller Posted May 22, 2015 Share Posted May 22, 2015 (edited) Hi Phpmadman. Can you tell me how to this on supply-order PDF? Edited May 22, 2015 by Niller (see edit history) Link to comment Share on other sites More sharing options...
PhpMadman Posted May 23, 2015 Share Posted May 23, 2015 It's the same thing. Override the HTMLTemplateSupplyOrderForm.php, and only the getContent function. And then before the smarty assign. Foreach the $supply_order_details and add warehouse to it. Link to comment Share on other sites More sharing options...
Niller Posted June 1, 2015 Share Posted June 1, 2015 Do you want to show me how: My htmlsupplyordertemplate is like this: <?php /* * 2007-2013 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2013 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ /** * @since 1.5 */ class HTMLTemplateSupplyOrderFormCore extends HTMLTemplate { public $supply_order; public $warehouse; public $address_warehouse; public $address_supplier; public $context; public function __construct(SupplyOrder $supply_order, $smarty) { $this->supply_order = $supply_order; $this->smarty = $smarty; $this->context = Context::getContext(); $this->warehouse = new Warehouse((int)$supply_order->id_warehouse); $this->address_warehouse = new Address((int)$this->warehouse->id_address); $this->address_supplier = new Address(Address::getAddressIdBySupplierId((int)$supply_order->id_supplier)); // header informations $this->date = Tools::displayDate($supply_order->date_add); $this->title = HTMLTemplateSupplyOrderForm::l('Supply order form'); } /** * @see HTMLTemplate::getContent() */ public function getContent() { $supply_order_details = $this->supply_order->getEntriesCollection((int)$this->supply_order->id_lang); $this->roundSupplyOrderDetails($supply_order_details); $this->roundSupplyOrder($this->supply_order); $tax_order_summary = $this->getTaxOrderSummary(); $currency = new Currency((int)$this->supply_order->id_currency); $this->smarty->assign(array( 'warehouse' => $this->warehouse, 'address_warehouse' => $this->address_warehouse, 'address_supplier' => $this->address_supplier, 'supply_order' => $this->supply_order, 'supply_order_details' => $supply_order_details, 'tax_order_summary' => $tax_order_summary, 'currency' => $currency, )); return $this->smarty->fetch($this->getTemplate('supply-order')); } /** * @see HTMLTemplate::getBulkFilename() */ public function getBulkFilename() { return 'supply_order.pdf'; } /** * @see HTMLTemplate::getFileName() */ public function getFilename() { return self::l('SupplyOrderForm').sprintf('_%s', $this->supply_order->reference).'.pdf'; } protected function getTaxOrderSummary() { $query = new DbQuery(); $query->select(' SUM(price_with_order_discount_te) as base_te, tax_rate, SUM(tax_value_with_order_discount) as total_tax_value '); $query->from('supply_order_detail'); $query->where('id_supply_order = '.(int)$this->supply_order->id); $query->groupBy('tax_rate'); $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); foreach ($results as &$result) { $result['base_te'] = Tools::ps_round($result['base_te'], 2); $result['tax_rate'] = Tools::ps_round($result['tax_rate'], 2); $result['total_tax_value'] = Tools::ps_round($result['total_tax_value'], 2); } unset($result); // remove reference return $results; } /** * @see HTMLTemplate::getHeader() */ public function getHeader() { $shop_name = Configuration::get('PS_SHOP_NAME'); $path_logo = $this->getLogo(); $width = $height = 0; if (!empty($path_logo)) list($width, $height) = getimagesize($path_logo); $this->smarty->assign(array( 'logo_path' => $path_logo, 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'title' => $this->title, 'reference' => $this->supply_order->reference, 'date' => $this->date, 'shop_name' => $shop_name, 'width_logo' => $width, 'height_logo' => $height )); return $this->smarty->fetch($this->getTemplate('supply-order-header')); } /** * @see HTMLTemplate::getFooter() */ public function getFooter() { $this->address = $this->address_warehouse; $free_text = array(); $free_text[] = HTMLTemplateSupplyOrderForm::l('DE: Discount excluded '); $free_text[] = HTMLTemplateSupplyOrderForm::l(' DI: Discount included'); $this->smarty->assign(array( 'shop_address' => $this->getShopAddress(), 'shop_fax' => Configuration::get('PS_SHOP_FAX'), 'shop_phone' => Configuration::get('PS_SHOP_PHONE'), 'shop_details' => Configuration::get('PS_SHOP_DETAILS'), 'free_text' => $free_text, )); return $this->smarty->fetch($this->getTemplate('supply-order-footer')); } /** * Rounds values of a SupplyOrderDetail object * @param array $collection */ protected function roundSupplyOrderDetails(&$collection) { foreach ($collection as $supply_order_detail) { $supply_order_detail->unit_price_te = Tools::ps_round($supply_order_detail->unit_price_te, 2); $supply_order_detail->price_te = Tools::ps_round($supply_order_detail->price_te, 2); $supply_order_detail->discount_rate = Tools::ps_round($supply_order_detail->discount_rate, 2); $supply_order_detail->price_with_discount_te = Tools::ps_round($supply_order_detail->price_with_discount_te, 2); $supply_order_detail->tax_rate = Tools::ps_round($supply_order_detail->tax_rate, 2); $supply_order_detail->price_ti = Tools::ps_round($supply_order_detail->price_ti, 2); } } /** * Rounds values of a SupplyOrder object * @param SupplyOrder $supply_order */ protected function roundSupplyOrder(SupplyOrder &$supply_order) { $supply_order->total_te = Tools::ps_round($supply_order->total_te, 2); $supply_order->discount_value_te = Tools::ps_round($supply_order->discount_value_te, 2); $supply_order->total_with_discount_te = Tools::ps_round($supply_order->total_with_discount_te, 2); $supply_order->total_tax = Tools::ps_round($supply_order->total_tax, 2); $supply_order->total_ti = Tools::ps_round($supply_order->total_ti, 2); } } Best regards Link to comment Share on other sites More sharing options...
PhpMadman Posted June 3, 2015 Share Posted June 3, 2015 Create /override/classes/HTMLTemplateSupplyOrderForm.php And paste the following code. <?php class HTMLTemplateSupplyOrderForm extends HTMLTemplateSupplyOrderFormCore { public function getContent() { $supply_order_details = $this->supply_order->getEntriesCollection((int)$this->supply_order->id_lang); // Start location patch foreach ($supply_order_details as &$order_detail) { $order_detail['warehouse_name'] = "--"; $order_detail['warehouse_location'] = "--"; if ($order_detail['id_warehouse'] != 0) { $warehouse = new Warehouse((int)$order_detail['id_warehouse']); $warehouse_location = $warehouse->getProductLocation($order_detail["product_id"],$order_detail["product_attribute_id"],$warehouse->id); $order_detail['warehouse_name'] = $warehouse->name; $order_detail['warehouse_location'] = $warehouse_location; } } // End location patch $this->roundSupplyOrderDetails($supply_order_details); $this->roundSupplyOrder($this->supply_order); $tax_order_summary = $this->getTaxOrderSummary(); $currency = new Currency((int)$this->supply_order->id_currency); $this->smarty->assign(array( 'warehouse' => $this->warehouse, 'address_warehouse' => $this->address_warehouse, 'address_supplier' => $this->address_supplier, 'supply_order' => $this->supply_order, 'supply_order_details' => $supply_order_details, 'tax_order_summary' => $tax_order_summary, 'currency' => $currency, )); return $this->smarty->fetch($this->getTemplate('supply-order')); } } It's untestad, but should work. Just edit supply-order.tpl and add $supply_order_detail->warehouse_location Link to comment Share on other sites More sharing options...
Niller Posted June 6, 2015 Share Posted June 6, 2015 Hey madmodules. Thanks for your answer but unfortunately not, nothing happens Link to comment Share on other sites More sharing options...
PhpMadman Posted June 6, 2015 Share Posted June 6, 2015 Hi. For the override to work you need to delete the class_index.php in the cache folder Link to comment Share on other sites More sharing options...
Niller Posted June 6, 2015 Share Posted June 6, 2015 (edited) Thanks for the code - but i get the white screen error when implementing Edited June 8, 2015 by Niller (see edit history) Link to comment Share on other sites More sharing options...
Niller Posted June 11, 2015 Share Posted June 11, 2015 Bump Link to comment Share on other sites More sharing options...
Charles42 Posted June 23, 2015 Share Posted June 23, 2015 Hi, I followed PhpMadman solution to implement warehouse location on PS 1.6.0.14 and it works like a charm. Thanks a lot !! I have a question. How can I override pdf/delivery-slip.tpl ? I tried to put this file in override/pdf/delivery-slip.tpl but it doesn't work. Do you have an idea ? Link to comment Share on other sites More sharing options...
tuk66 Posted June 23, 2015 Share Posted June 23, 2015 Just replace the old /pdf/delivery-slip.tpl file. Link to comment Share on other sites More sharing options...
Charles42 Posted June 23, 2015 Share Posted June 23, 2015 Hi Tuk66, Thanks for your reply.. If I understand, I can't override this file, I have to make some change directly on this file ? Link to comment Share on other sites More sharing options...
tuk66 Posted June 23, 2015 Share Posted June 23, 2015 You have to use a text editor. So download the file, do a small change, upload back, test, and repeat if needed. Link to comment Share on other sites More sharing options...
PhpMadman Posted June 23, 2015 Share Posted June 23, 2015 placing it in THEME/pdf/ might work. Works for the other tp's 1 Link to comment Share on other sites More sharing options...
prstshp_joe Posted June 24, 2015 Share Posted June 24, 2015 On Prestashop 1.6 $product.warehouse_name and $product.warehouse_location did not work for me. I have to use $order_detail.warehouse_location and $order_detail.warehouse_name instead in pdf\delivery-slip.tpl Anyway, :thumbsup: and thank you! 1 Link to comment Share on other sites More sharing options...
Niller Posted July 7, 2015 Share Posted July 7, 2015 Have any one succeded on suppy order form? Link to comment Share on other sites More sharing options...
Nixnix Posted July 23, 2015 Share Posted July 23, 2015 Finally I got it ! It wasn't an incompatibilty with a module. I just had to check the advanced stock management in the product concerned I have to do a SQL query to do that on all my products. Merci , Merci beaucoup messieurs ;-) Nice! Can anyone advise; how can I make an SQL query to activate Advanced Stock Management for all products at once? We are manually assigning warehouse location for each product now (and clicking this checkbox for each product) and when we currently get orders, the orders get split up in Prestashop (customer makes 1 order, we get 2 invoices: one for the ones with advanced stock management and one for those without it). So we just quickly want to activate it for everything on the fly. Thanks in advance. Link to comment Share on other sites More sharing options...
PhpMadman Posted July 23, 2015 Share Posted July 23, 2015 Hi. Export all products, with name, and id, Wholesale price and qty. Then fix a csv and import them again. In the csv you can add the following Advanced Stock Management (1/0) Depends on stock (1/0) Warehouse (id_warehouse) Qty will be automaticlly be assigned to the warehouse. Wholeshale price will be assigned as the product cost in warehouse, if i remember correctlly Just remember to to a test run on one product and also check the Force all ID numbers switch. That will assign warehouse for all your products. As for warehouse_location. It's not supported by import, but i do have a script for it somewhere. I'll look for it. 1 Link to comment Share on other sites More sharing options...
Nixnix Posted July 24, 2015 Share Posted July 24, 2015 (edited) As for warehouse_location. It's not supported by import, but i do have a script for it somewhere. I'll look for it. Cool, thanks PhpMadman! Is there any way we can also export the entire catalog of products with warehouse_location included, so we can easily double check that everything really is assigned a location? When I do a normal product export there is barely any information but I guess it would be possible with a sql query. I just don't know how. Edited July 24, 2015 by Nixnix (see edit history) Link to comment Share on other sites More sharing options...
Nixnix Posted September 10, 2015 Share Posted September 10, 2015 Sorry to bump this thread, but does anyone know how to export a product list with warehouse location included? We still, months later, receive orders where Prestashop splits our orders into two (creating a customer support mess and confused customers) because some products have a warehouse location, and some don't. And there is no way for us to see out entire catalog with warehouse location info. I tried this SQL query variant: SELECT * FROM ps_warehouse_product_location WHERE ps_warehouse_product_location.id_warehouse_product_location But it seems to just show the stuff which already has a location. I'm not experienced with database things, as you see. Link to comment Share on other sites More sharing options...
tuk66 Posted September 10, 2015 Share Posted September 10, 2015 Try SELECT * FROM ps_product p LEFT OUTER JOIN ps_warehouse_product_location wpl ON (p.id_product = wpl.id_product) LEFT OUTER JOIN ps_warehouse w ON (wpl.id_warehouse = w.id_warehouse) for all products Link to comment Share on other sites More sharing options...
Nixnix Posted September 10, 2015 Share Posted September 10, 2015 Thanks tuk66! That's awesome! I just noticed there is a lot of products with blank id_product in my new exported list. How can I add Product Name to this query, to get a clue what these empty rows might be? Link to comment Share on other sites More sharing options...
tuk66 Posted September 10, 2015 Share Posted September 10, 2015 SELECT * FROM ps_product p LEFT OUTER JOIN ps_product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = 1) LEFT OUTER JOIN ps_warehouse_product_location wpl ON (p.id_product = wpl.id_product) LEFT OUTER JOIN ps_warehouse w ON (wpl.id_warehouse = w.id_warehouse) Change the 1 to another ID for different language. Link to comment Share on other sites More sharing options...
Nixnix Posted September 10, 2015 Share Posted September 10, 2015 Thanks, but with this query I get a red warning in PS 1.6.0.9: When multiple tables are used, each attribute must refer back to a table. Link to comment Share on other sites More sharing options...
tuk66 Posted September 10, 2015 Share Posted September 10, 2015 Use this query in phpMyAdmin. It doesn't work in SQL Manager. 1 Link to comment Share on other sites More sharing options...
coMegaWebMaster Posted January 6, 2017 Share Posted January 6, 2017 Greetings all Am trying to make this: Can you help please? With kind regards, Alexander. Link to comment Share on other sites More sharing options...
coMegaWebMaster Posted January 15, 2017 Share Posted January 15, 2017 I thought it would be standard to have the warehouse location on this slip, if there is a module for this then please advice. With kind regards, Alexander. Link to comment Share on other sites More sharing options...
tuk66 Posted January 16, 2017 Share Posted January 16, 2017 Here is one example (by M4PDF) http://www.presta-addons.com/pdf/Delivery slips with images and location.pdf Link to comment Share on other sites More sharing options...
coMegaWebMaster Posted January 17, 2017 Share Posted January 17, 2017 Hi tuk66 , bought the module and very happy with all the extra's in it, thanks Link to comment Share on other sites More sharing options...
Recommended Posts