Reference

Voucher

Whenever you’re dealing with a voucher in your template, you’re working with a Voucher object. A voucher is the Commerce purchasable customers buy, and each purchase creates one or more Code objects that customers redeem. You can fetch vouchers with a voucher query.

Properties

id

The ID of the voucher.

title

The voucher’s title.

name

The voucher’s title. This is the same as title, and is available because Commerce refers to a purchasable’s name.

url

The URL of the voucher’s own page. This is null when its voucher type has no URI format.

purchasableId

The ID Commerce uses for the voucher as a purchasable, which is the same as its id. Use it when adding the voucher to the cart.

type

The voucher type the voucher belongs to.

typeId

The ID of the voucher’s voucher type.

price

The price of the voucher. When the voucher has a custom amount, the customer’s chosen amount is used instead.

customAmount

Whether customers choose the voucher’s amount when they buy it, rather than paying its set price. See Custom Amounts.

sku

The voucher’s SKU, which identifies it in Commerce.

status

The voucher’s status, which is live, pending, expired or disabled. An enabled voucher is pending before its post date, expired after its expiry date and live in between.

enabled

Whether the voucher is enabled.

taxCategoryId

The ID of the tax category Commerce uses when calculating tax on this voucher.

taxCategory

The tax category Commerce uses when calculating tax on this voucher.

shippingCategoryId

The ID of the shipping category Commerce uses when calculating shipping for this voucher.

shippingCategory

The shipping category Commerce uses when calculating shipping for this voucher.

postDate

The date the voucher goes on sale.

expiryDate

The date the voucher stops being available for sale. This is null when it doesn’t expire.

Methods

getCpEditUrl()

Returns the URL to edit this voucher in the control panel.

getPdfUrl()

Returns: string

Returns the URL to download the PDF of the codes bought in a Commerce line item. Use it on an order confirmation page or email to link to the customer’s voucher PDF. See PDF Vouchers.

getCodes()

Returns: array

Returns the Code objects created for a Commerce line item, one for each voucher bought in it.

getProduct()

Returns the voucher itself. Commerce templates often call purchasable.product, so this lets the same template code work for vouchers.

Last updated: Nov 13, 2026, 3:16:25 PM