CoolCMS API

CartVoucher extends BaseEntity
in package
implements IdentifiableInterface uses IdentifiableTrait

AbstractYes

Discount code applied in a persistent cart: only the code, no validation or value (price and validity are always verified by checkout, not by the cart).

Surrogate PK, same reason as CartItem. CartManager deduplicates the pair (cart, code) case-insensitively in PHP (mb_strtolower) before building entities; the unique index (case-insensitive collation) is only a fallback.

Tags
template
Attributes
#[MappedSuperclass]
#[TableAlias]
$alias: 'cartVoucher'

Table of Contents

Interfaces

IdentifiableInterface
Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).

Properties

$cart  : TCart|null
$code  : string
$id  : int|null

Methods

__construct()  : mixed
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
getAllTraits()  : array<string, string>
Returns all traits the class uses, including those used by parent classes and nested traits.
getCart()  : TCart|null
getCode()  : string
getId()  : int|null
isPersisted()  : bool
setCart()  : $this
setCode()  : $this
setId()  : $this
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$code

protected string $code = ''
Attributes
#[Column]
$name: 'code'
$type: 'string'
$length: 64

$id

protected int|null $id = null
Attributes
#[Column]
$name: 'cart_voucher_id'
$type: 'integer'
$options: ['unsigned' => true]
#[GeneratedValue]
#[Id]

Methods

__construct()

public __construct([int|null $id = null ][, mixed $cart = null ][, string $code = '' ]) : mixed
Parameters
$id : int|null = null
$cart : mixed = null
$code : string = ''

callInitMethods()

Calls `init{TraitName}()` for every used trait that defines such a method.

public callInitMethods() : void

getAllTraits()

Returns all traits the class uses, including those used by parent classes and nested traits.

public getAllTraits() : array<string, string>
Return values
array<string, string>

getCart()

public getCart() : TCart|null
Return values
TCart|null

getCode()

public getCode() : string
Return values
string

setCart()

public setCart(TCart|null $cart) : $this
Parameters
$cart : TCart|null
Return values
$this

setCode()

public setCode(string $code) : $this
Parameters
$code : string
Return values
$this

setId()

public setId(int|null $id) : $this
Parameters
$id : int|null
Return values
$this

getTraitsRecursive()

Walks the trait list recursively and collects nested traits too.

private static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
$traits : array<string, string>
Return values
array<string, string>
On this page

Search results