Customize EDD pdf vouchers with shortcodes support

“Customize EDD pdf vouchers with shortcodes support” Documentation by “WPWeb”

Adding shortcode in Voucher Template

Go to Voucher Templates menu under the Downloads menu and click on Edit Voucher link

Edit Voucher Templates

Click on Custom blok button to insert Custom block in Voucher Tempalte. After inserting it click on Edit icon of Custom block

Custom Block Supported Shortcodes

Here is the list of Supported Shortcodes.

{redeem} - displays the voucher redeem instruction.
{sitelogo} - displays the voucher site logo.
{vendorlogo} - displays the vendor logo.
{expiredate} - displays the voucher expire date.
{vendoraddress} - displays the vendor address.
{siteurl} - displays the site url.
{location} - displays the location(s).
{buyername} - displays the buyer name.
{buyeremail} - displays the buyer email.
{orderid} - displays the order id.
{orderdate} - displays the order date.
{productname} - displays the product name.
{productprice} - displays the product price.
{codes} - displays the voucher code(s).
{recipientname} - displays the recipient name for voucher code(s).
{recipientemail} - displays the recipient email for voucher code(s).
{recipientmessage} - displays the recipient message for voucher code(s).
{payment_method} - displays the payment method of the order.

Creating own shortcode support in Voucher Template

Adding our own shortcode support to pdf voucher is very simple, it is just one function attached to a filter. The structure of the function looks like this:

Replace the place holders with actual values and we get this

That's it. Now suppose you wanted to display some predefined value for this shortcode in the preview of the Pdf, Please add below code :