Screenshot of the "Print" view mode configuration page.
Screenshot of an example of how to implement custom template for Commerce Print module.

Commerce Print

A small utility module to help users print Commerce Orders.

"Print" action doesn't rely on any third party library. We have choosen to use browsers' built-in "Print to File" functionality.

We think it's the most easy, efficient and certainly cross-platform way to give users the ability to print to PDF.

Installation

Use [Composer](https://getcomposer.org/) to get Drupal + Commerce + Commerce Print.

```
composer require drupal/commerce_print
```

Introduction

Commerce Print adds a few things for you:

  • The Print display mode for Commerce Order types.
  • The Print link which needs to be placed in the display mode.

Theming

If you need to configure the Print display mode, go to Admin > Store > Config > Order > Order Types > Default.

Some default templates are provided inside commerce_print/templates/.

Copy/paste them in your custom theme as needed for customization.

Magic link for printing

As state above, we do not implement any third party library for print to PDF.

We also choose to use a universal HTML/Javascript implementation for the button with javascript:if(window.print)window.print(). It is kind of old-school/ugly but, hey, it works! :)

    <div class="commerce-print-action">
      <a class="button button--primary" href="javascript:if(window.print)window.print()">{{ 'Print'|t }}</a>
    </div>

You are free to create your own JS or Drupal Behavior if you feel like so.

Feel free to open an issue and suggest a new (better) implementation.

We are totally open to suggestions.

Related modules

* Entity Print module https://www.drupal.org/project/entity_print: definitely the most complete module if you want to implement a Print to PDF functionality on your website.

---

Questions? Please create an issue or Contact me.

Project information

Releases