Displaying Voucher Codes#

Once a user has purchased a gift voucher, its important to actually provide the voucher code for them to pass on to the required party. For example, on our order summary template (shop/customer/order.html for example), we have the following code looping through line items for the order.

{% if craft.giftVoucher.isVoucher(item) %}
    {% for voucherCode in item.purchasable.getCodesForLineItem(item) %}
        Code: {{ voucherCode }}<br />
    {% endfor %}
{% endif %}

Because multiple vouchers can be purchased for one line item, its important to loop through potentially multiple unique voucher codes as above.

If you're looking for something a little prettier than simply showing the code in your order confirmation page or email, you may want to look at generating a PDF Template.

Previous ← Single Voucher Next Redeeming Voucher Codes →

Get started with Gift Voucher

Available for Craft 4. Get it from the plugin store.