SwissUpLabs Logo

Use cases

Add PDF attachment to email

Email Attachment

To attach PDF to sales emails, enable the setting in the module configuration:

Stores > Configuration > Swissup > PDF Invoices > Order/Invoice/Shipment/Credit Memo > Send PDF as an attachment in the email

Please note that download link won’t work when Sales > Sales Emails > General Settings > Asynchronous sending is enabled.

PDF download link

To display download PDF link in emails, edit email template under Marketing > Email Templates and add the following code:

For Magento 2.3.6+/2.4.0+:

  • for order PDF

    {{block class="Swissup\PdfInvoice\Block\Email\Documents" area="frontend" order_id=$order_id}}
    
  • for invoice PDF

    {{block class="Swissup\PdfInvoice\Block\Email\Documents" area="frontend" invoice_id=$invoice_id order_id=$order_id}}
    
  • for shipment PDF

    {{block class="Swissup\PdfInvoice\Block\Email\Documents" area="frontend" shipment_id=$shipment_id order_id=$order_id}}
    
  • for credit memo PDF

    {{block class="Swissup\PdfInvoice\Block\Email\Documents" area="frontend" creditmemo_id=$creditmemo_id order_id=$order_id}}
    

For older Magento versions:

  • for order PDF

    {{block class="Swissup\PdfInvoice\Block\Email\Documents" area="frontend" order=$order}}
    
  • for invoice PDF

    {{block class="Swissup\PdfInvoice\Block\Email\Documents" area="frontend" order=$order invoice=$invoice}}
    
  • for shipment PDF

    {{block class="Swissup\PdfInvoice\Block\Email\Documents" area="frontend" order=$order shipment=$shipment}}
    
  • for credit memo PDF

    {{block class="Swissup\PdfInvoice\Block\Email\Documents" area="frontend" order=$order creditmemo=$creditmemo}}
    

Using barcodes and QR codes

You can use barcodes and QR codes in PDF templates.

Barcodes

Barcode can be added with barcode tag:

<barcode code="978-0-9542246-0" type="EAN13" text="1" size="1" height="1" />
Attribute Description
code Specifies the code to translate to a barcode (required)
type Specifies the type of barcode (default: EAN13)
text Specifies whether to show the code at the top of an EAN13 barcode (default: 0)
size Specifies the size of the barcode (default: 1)
height Specifies the height of the barcode (default: 1)

You can find available barcode types and examples on mPDF barcode manual

QR codes

QR code can be added with barcode tag with type="QR" attribute:

<barcode code="Your message\ngoes here" type="QR" size="0.8" error="M" disableborder="1" />
Attribute Description
error Specifies QR code error level: L, M, Q, H (default: L)
disableborder Display QR code without border (default: 0)

QR code code can contain \n or \r\n sequences that will be converted to LF or CRLF characters.

If you get error when using QR code, make sure you have mpdf/qrcode installed.

It can be installed with the following SSH command:

composer require mpdf/qrcode

Display product image in items table

To display product image in items table in PDF, add image="1" param to items code:

{{layout area="frontend" handle="sales_email_order_invoice_items" invoice_id=$invoice_id order_id=$order_id image="1"}}

Display product SKU barcode or QR code in items table

To display product sku QR code in items table in PDF, add barcode="QR" param to items code:

{{layout area="frontend" handle="sales_email_order_invoice_items" invoice_id=$invoice_id order_id=$order_id barcode="QR"}}

You can use all supported barcode types, e.g. barcode=”QR” or barcode=”C39”.

Display Purchase Order information

A purchase order (PO) is one of default Magento payment methods. You can read more about it at Magento docs.

To display PO number use code below:

{{depend order.getPayment().getPoNumber()}}
   <div><strong>{{trans "Purchase Order Number"}}</strong> {{var order.getPayment().getPoNumber()|raw}}</div>
{{/depend}}
Edit this Page