PrestaShop show total product weight in PDF invoice
To show total product weight in PrestaShop PDF invoice, edit file.
1 |
vi classes/pdf/HTMLTemplateInvoice.php |
Inside function getContent(), on line 166, find
1 |
foreach ($order_details as $id => &$order_detail) { |
Replace with
1 2 3 |
$sokTotalWeight = 0; foreach ($order_details as $id => &$order_detail) { $sokTotalWeight += $order_detail["product_weight"] * $order_detail["product_quantity"]; |
On around line 332, find
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$data = array( 'order' => $this->order, 'order_invoice' => $this->order_invoice, 'order_details' => $order_details, 'carrier' => $carrier, 'cart_rules' => $cart_rules, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address), 'tax_excluded_display' => $tax_excluded_display, 'display_product_images' => $display_product_images, 'layout' => $layout, 'tax_tab' => $this->getTaxTabContent(), 'customer' => $customer, 'footer' => $footer, 'ps_price_compute_precision' => _PS_PRICE_COMPUTE_PRECISION_, 'round_type' => $round_type, 'legal_free_text' => $legal_free_text, ); |
Above $data line, add
1 |
$sokTotalWeight = $sokTotalWeight . ' ' . Configuration::get('PS_WEIGHT_UNIT'); |
Inside the array, add
1 |
'sokTotalWeight' => $sokTotalWeight, |
Now we need to edit the PDF template file.
1 |
vi pdf/invoice.tpl |
Inside the file, find
1 |
{$legal_free_text|escape:'html':'UTF-8'|nl2br}</p> |
Add above
1 |
Total Weight: {$sokTotalWeight}<br/> |
You can place this text in any place in the document based on where you need it to show in your PDF document.
To show order comment in PDF invoice, see PrestaShop show order comment in PDF invoice
Back to PrestaShop