PrestaShop show total product weight in PDF invoice
To show total product weight in PrestaShop PDF invoice, edit file.
vi classes/pdf/HTMLTemplateInvoice.php
Inside function getContent(), on line 166, find
foreach ($order_details as $id => &$order_detail) {
Replace with
$sokTotalWeight = 0; foreach ($order_details as $id => &$order_detail) { $sokTotalWeight += $order_detail["product_weight"] * $order_detail["product_quantity"];
On around line 332, find
$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
$sokTotalWeight = $sokTotalWeight . ' ' . Configuration::get('PS_WEIGHT_UNIT');
Inside the array, add
'sokTotalWeight' => $sokTotalWeight,
Now we need to edit the PDF template file.
vi pdf/invoice.tpl
Inside the file, find
{$legal_free_text|escape:'html':'UTF-8'|nl2br}
Add above
Total Weight: {$sokTotalWeight}
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