PDF documents view permissions

By default the PDF Invoices & Packing Slips for WooCommerce plugin restricts the view access for PDF documents to only users with manage_woocommerce capabilities or to logged-in customers from the ‘My Account‘ page on the frontend.

Sometimes there is a need to display a button or link for viewing and/or downloading the document, outside these parameters – which requires a different approach. For example, one might need to display the Invoice link on the thank you page or in an email.

Set permissions #

Path: WooCommerce > PDF Invoices > Advanced > Settings > Document link access type.

An image of the settings
An image of the settings

This setting has three options:

  • Logged in (recommended)
  • Guest
  • Full

Logged in (recommended) #

Documents can be accessed by logged-in users only.
This is the default option.

Guest #

Document can be accessed by logged in and guest users.
With this option selected, being logged-in is not necessary.

  • If the user is logged-in, the login access will be used to grant permission.
  • If the user is not logged-in, a unique/special key to grant access.

The technique behind this setting is that: Instead of relying on nonces, the plugin generates a unique key for the document-order combination. If the order unique key corresponds to the order being viewed, the user is allowed to see the PDF document.

Full #

Documents can be accessed by everyone with the link.
This is ideal for situations where all the information is public.