0

I want to change the design and layout of my packing-slip pdf print-outs to make a simple and clean print for the employes to work through.

Is there any extension / tutorial / anything else which shows how to make this possible ?

4

To edit the packing list, or any other PDF docs such as invoice you need to override the files contained within

Magento\Sales\Model\Order\Pdf

For example if wanted to add the price to the packing list

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <preference for="Magento\Sales\Model\Order\Pdf\Items\Shipment\DefaultShipment"
                type="Example\Sales\Model\Order\Pdf\Items\Shipment\DefaultShipment"/>

</config>

Then copy the file "Magento\Sales\Model\Order\Pdf\Items\Shipment\DefaultShipment" to your app/code file, change the name spacing to match the XML above and add the following on around line number 81

 // draw item Prices
        $i = 0;
        $prices = $this->getItemPricesForDisplay();
        $feedPrice = 395;
        $feedSubtotal = $feedPrice + 70;
        $feedTax = $feedSubtotal + 70;
        foreach ($prices as $priceData) {
            if (isset($priceData['label'])) {
                // draw Price label
                $lines[$i][] = ['text' => $priceData['label'], 'feed' => $feedPrice, 'align' => 'right'];
                // draw Subtotal label
                $lines[$i][] = ['text' => $priceData['label'], 'feed' => $feedSubtotal, 'align' => 'right'];
                $i++;
            }
            // draw Price
            $lines[$i][] = [
                'text' => $priceData['price'],
                'feed' => $feedPrice,
                'font' => 'bold',
                'align' => 'right',
            ];
            // draw Subtotal
            $lines[$i][] = [
                'text' => $priceData['subtotal'],
                'feed' => $feedSubtotal,
                'font' => 'bold',
                'align' => 'right',
            ];
            $i++;
        }

        // draw Tax
        $lines[0][] = [
            'text' => $order->formatPriceTxt($item->getTaxAmount()),
            'feed' => $feedTax,
            'font' => 'bold',
            'align' => 'right',
        ];
| improve this answer | |
  • Thanks its works but in $item = $this->getItem(); some data are missing like subtotal, tax etc. can you tell me how can I fetch all the data in $item ? – David Coder Oct 8 '18 at 5:39
0

I don't know if you already did this, but for future people that come across this, here is a video that somehow explains it. https://www.youtube.com/watch?v=_baegIF0v48&feature=youtu.be

| improve this answer | |
0

You can take a look at this module https://www.vnecoms.com/magento2-pdf-invoice-pro.html. This module allow you customize your template directly inside backend. Use editor allow you can create template in a few clicks. Support magento 2.2.x

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.