Reference

Code

Whenever you’re dealing with a code in your template, you’re working with a Code object. A code is what a customer enters at checkout to spend a voucher’s value, and it’s created when a Voucher is bought or generated in the control panel. You can fetch codes with a code query.

Properties

id

The ID of the code.

voucherId

The ID of the Voucher the code was created for.

voucher

The Voucher the code was created for.

voucherType

The voucher type of the code’s voucher.

orderId

The ID of the Commerce order the voucher was bought in. This is null for a code generated in the control panel.

order

The Commerce order the voucher was bought in. This is null for a code generated in the control panel.

lineItemId

The ID of the Commerce line item the voucher was bought in. This is null for a code generated in the control panel.

lineItem

The Commerce line item the voucher was bought in. This is null for a code generated in the control panel.

codeKey

The unique code a customer enters to redeem the voucher’s value.

originalAmount

The amount the code was worth when it was created. It doesn’t change as the code is redeemed.

currentAmount

The unredeemed amount recorded for the code. Because vouchers can be redeemed multiple times, this amount can be used all at once or across several orders. Active checkout holds reduce the amount currently available without changing this value until the order completes.

expiryDate

The date the code can no longer be redeemed. This is null when it doesn’t expire.

Methods

getCpEditUrl()

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

getRedemptions()

Returns the redemptions of this code, each recording an amount of the code used on an order.

getAvailableAmount()

Returns the amount available to a new checkout after active holds are deducted from currentAmount.

getHeldAmount()

Returns the total value currently held by unresolved checkouts.

getReservations()

Returns the active checkout holds for the code. A hold remains active until its order completes, an explicit decline releases it or an administrator releases it after reviewing the payment state.

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