Configuration
You can customise Gift Voucher’s settings using a PHP configuration file. This is optional: each setting has a default, so you only need to include the values you want to change.
To override a setting, create gift-voucher.php in your Craft project’s /config directory and return an array of setting names and values. For example, the following will generate voucher code keys with 12 characters:
<?php
return [
'codeKeyLength' => 12,
];All other settings keep their defaults. Add any further settings you want to change to the same array. The options below explain the available settings and their defaults.
Configuration Options
Type: int · Default: 0
Set a default expiry (in months). 0 to disable.
Type: int · Default: 10
Set the number of characters for generated codes to be.
Type: int · Default: 500
The maximum number of gift vouchers an order can purchase, counted across all voucher products and line item options. Set a positive integer. Increase the limit if your store needs larger purchases, allowing for the time required to generate every code during checkout.
The limit is checked when validating a cart, before starting payment and before checkout without payment. Existing oversized carts must reduce their quantities before checking out. Completed orders and completion callbacks for payments already in progress remain eligible for full fulfilment; the limit never truncates the number of codes issued. This setting does not change the separate control-panel bulk-generation limit.
Type: string · Default: 'ACDEFGHJKLMNPQRTUVWXYZ234679'
Supply valid characters to be used in code generation.
Type: string · Default: 'shop/_pdf/voucher'
Set the path to your PDF.
Type: string · Default: 'Gift-Voucher'
Set the PDF filename format for downloads and email attachments, without the .pdf extension. If the format renders an empty filename, Gift-Voucher is used instead.
Custom formats can use order data. Existing saved or configured formats continue to override the default, including Voucher-{number}. The full order number grants access to all gift vouchers purchased in that order, so avoid including it in filenames or PDFs intended for an individual recipient.
Type: bool · Default: false
Whether to allow remote images in the PDF.
Type: string · Default: 'letter'
Sets the paper size for the PDF.
Type: string · Default: 'portrait'
Sets the paper orientation for the PDF.
Type: string · Default: 'beforeTax'
Controls when the adjuster should be applied. Valid options are beforeTax (default) and afterTax.
Type: bool · Default: true
Whether shipping costs should be included in voucher redemption.
Type: array · Default: []
A collection of Commerce Email UIDs that Gift Voucher should automatically attach the voucher PDF to.
To populate the attachPdfToEmails setting, you'll need the UIDs of Commerce Emails. To determine these, create your Commerce emails, then look up the commerce_emails table in your database. Use the values in the uid column in an array, passing true/false for whether the PDF should be attached to the email. For example:
'attachPdfToEmails' => [
'a27c0c16-71c8-422f-a09f-094264876319' => false,
'd0b374ad-4394-48ea-8ecb-f0efc0bfeec5' => true,
],Control Panel
You can also manage configuration settings through the Control Panel by visiting Settings → Gift Voucher.