Developers

Voucher

Whenever you're dealing with a vouchers in your template, you're actually working with a Voucher object.

Properties

id

Type: int|null

ID of the voucher.

title

Type: string|null

The voucher name/title.

name

Type: string|null

The voucher name/title.

url

Type: string|null

The URL to this single voucher.

purchasableId

Type: int|null

Returns this vouchers id - as vouchers are purchasables.

type

Type: VoucherType|null

The voucher's product type.

typeId

Type: int|null

The voucher's voucher type ID

price

Type: float|null

The listing price of the voucher.

customAmount

Type: float|null

Whether this voucher should have a custom (user-provided) amount.

sku

Type: string|null

The sku of the voucher.

status

Type: string|null

live, pending or expired based on postDate and expiryDate dates. Pending are vouchers with a future postDate date.

enabled

true or false

taxCategoryId

Type: int|null

The ID for the tax category this voucher uses when their tax calculations are made.

taxCategory

Type: TaxCategory

The tax category this voucher uses when their tax calculations are made.

shippingCategoryId

Type: int|null

The ID for the shipping category this voucher uses when their shipping calculations are made.

shippingCategory

Type: ShippingCategory

The shipping category this voucher uses when their shipping calculations are made.

postDate

Type: DateTime|null

The date this voucher is available for sale.

expiryDate

Type: DateTime|null

The date this voucher will no longer be available for sale.

Methods

getCpEditUrl()

The url to edit this voucher in the control panel.

getPdfUrl(LineItem $lineItem, $option = null)

Returns: string

Get the PDF URL for this voucher and Line Item (opens new window).

getCodes(LineItem $lineItem)

Get all Code's for a provided Line Item (opens new window) and voucher.

getProduct()

Returns: static

Convenience method for native Commerce product behaviour.