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
The ID of the code.
The ID of the Voucher the code was created for.
The Voucher the code was created for.
The voucher type of the code’s voucher.
The ID of the Commerce order the voucher was bought in. This is null for a code generated in the control panel.
The Commerce order the voucher was bought in. This is null for a code generated in the control panel.
The ID of the Commerce line item the voucher was bought in. This is null for a code generated in the control panel.
The Commerce line item the voucher was bought in. This is null for a code generated in the control panel.
The unique code a customer enters to redeem the voucher’s value.
The amount the code was worth when it was created. It doesn’t change as the code is redeemed.
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.
The date the code can no longer be redeemed. This is null when it doesn’t expire.
Methods
Returns the URL to edit this code in the control panel.
Returns the redemptions of this code, each recording an amount of the code used on an order.
Returns the amount available to a new checkout after active holds are deducted from currentAmount.
Returns the total value currently held by unresolved checkouts.
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.