CoolCMS API

Cart extends Cart
in package

Persistent shopping cart stored in the database, the alternative to the default session storage (chosen per deployment by `%eshop.cart.storage%`, see {@see \App\UI\Front\Eshop\Models\Mappers\CartMapperFactory}).

Tags
extends
Attributes
#[Entity]
#[Table]
$name: 'cms_mod_eshop_carts'
#[TableAlias]
'cart'

Table of Contents

Properties

$checkoutData  : string|null
$currency  : TCurrency|null
$id  : int|null
$insertDatetime  : DateTime|null
$items  : Collection<int, CartItem>
$language  : TLanguage|null
$sessionKey  : string
$updateDatetime  : DateTime|null
$user  : TUser|null
$vouchers  : Collection<int, CartVoucher>

Methods

__construct()  : mixed
addItem()  : $this
addVoucher()  : $this
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.
getCheckoutData()  : string|null
getCurrency()  : TCurrency|null
getId()  : int|null
getInsertDatetime()  : DateTime|null
getItems()  : Collection<int, TItem>
getLanguage()  : TLanguage|null
getOwnerUserId()  : int|null
getSessionKey()  : string
getUpdateDatetime()  : DateTime|null
getUser()  : TUser|null
getVouchers()  : Collection<int, TVoucher>
isPersisted()  : bool
setCheckoutData()  : $this
setCurrency()  : $this
setId()  : $this
setInsertDatetime()  : $this
setItems()  : $this
setLanguage()  : $this
setSessionKey()  : $this
setUpdateDatetime()  : $this
setUser()  : $this
setVouchers()  : $this
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$checkoutData

protected string|null $checkoutData = null
Attributes
#[Column]
$name: 'checkout_data'
$type: 'text'
$nullable: true

$currency

protected TCurrency|null $currency = null
Attributes
#[JoinColumn]
$name: 'cms_system_currencies_currency_id'
$referencedColumnName: 'currency_id'
$nullable: true
$onDelete: 'SET NULL'
#[ManyToOne]
$targetEntity: \App\UI\Api\System\Models\Entities\Currency::class
$fetch: 'LAZY'

$id

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

$insertDatetime

protected DateTime|null $insertDatetime = null
Attributes
#[Column]
$name: 'insert_datetime'
$type: 'datetime'
#[ExternalReadonly]

$items

protected Collection<int, CartItem> $items
Attributes
#[OneToMany]
$targetEntity: \App\UI\Api\Eshop\Models\Entities\CartItem::class
$mappedBy: 'cart'
$cascade: ['persist', 'remove']
$orphanRemoval: true
$fetch: 'LAZY'

$language

protected TLanguage|null $language = null
Attributes
#[JoinColumn]
$name: 'cms_system_languages_language_id'
$referencedColumnName: 'language_id'
$nullable: true
$onDelete: 'SET NULL'
#[ManyToOne]
$targetEntity: \App\UI\Api\System\Models\Entities\Language::class
$fetch: 'LAZY'

$sessionKey

protected string $sessionKey = ''
Attributes
#[Column]
$name: 'session_key'
$type: 'string'
$length: 64
#[FieldAccess]
$read: Audience::Internal
$insert: Audience::All
$update: Audience::All

$updateDatetime

protected DateTime|null $updateDatetime = null
Attributes
#[Column]
$name: 'update_datetime'
$type: 'datetime'
$nullable: true
#[ExternalReadonly]

$user

protected TUser|null $user = null
Attributes
#[JoinColumn]
$name: 'cms_system_users_user_id'
$referencedColumnName: 'user_id'
$nullable: true
$onDelete: 'SET NULL'
#[ManyToOne]
$targetEntity: \App\UI\Api\System\Models\Entities\User::class
$fetch: 'LAZY'

$vouchers

protected Collection<int, CartVoucher> $vouchers
Attributes
#[OneToMany]
$targetEntity: \App\UI\Api\Eshop\Models\Entities\CartVoucher::class
$mappedBy: 'cart'
$cascade: ['persist', 'remove']
$orphanRemoval: true
$fetch: 'LAZY'

Methods

__construct()

public __construct([int|null $id = null ][, string $sessionKey = '' ][, mixed $user = null ][, mixed $currency = null ][, mixed $language = null ][, string|null $checkoutData = null ][, DateTime|null $insertDatetime = null ][, DateTime|null $updateDatetime = null ][, Collection $items = new ArrayCollection() ][, Collection $vouchers = new ArrayCollection() ]) : mixed
Parameters
$id : int|null = null
$sessionKey : string = ''
$user : mixed = null
$currency : mixed = null
$language : mixed = null
$checkoutData : string|null = null
$insertDatetime : DateTime|null = null
$updateDatetime : DateTime|null = null
$items : Collection = new ArrayCollection()
$vouchers : Collection = new ArrayCollection()

addItem()

public addItem(TItem $item) : $this
Parameters
$item : TItem
Return values
$this

addVoucher()

public addVoucher(TVoucher $voucher) : $this
Parameters
$voucher : TVoucher
Return values
$this

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>

getCheckoutData()

public getCheckoutData() : string|null
Return values
string|null

getCurrency()

public getCurrency() : TCurrency|null
Return values
TCurrency|null

getInsertDatetime()

public getInsertDatetime() : DateTime|null
Return values
DateTime|null

getItems()

public getItems() : Collection<int, TItem>
Return values
Collection<int, TItem>

getLanguage()

public getLanguage() : TLanguage|null
Return values
TLanguage|null

getSessionKey()

public getSessionKey() : string
Return values
string

getUpdateDatetime()

public getUpdateDatetime() : DateTime|null
Return values
DateTime|null

getUser()

public getUser() : TUser|null
Return values
TUser|null

getVouchers()

public getVouchers() : Collection<int, TVoucher>
Return values
Collection<int, TVoucher>

setCheckoutData()

public setCheckoutData(string|null $checkoutData) : $this
Parameters
$checkoutData : string|null
Return values
$this

setCurrency()

public setCurrency(TCurrency|null $currency) : $this
Parameters
$currency : TCurrency|null
Return values
$this

setId()

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

setInsertDatetime()

public setInsertDatetime(DateTime|null $insertDatetime) : $this
Parameters
$insertDatetime : DateTime|null
Return values
$this

setItems()

public setItems(Collection<int, TItem>|array<int, TItem> $items) : $this
Parameters
$items : Collection<int, TItem>|array<int, TItem>
Return values
$this

setLanguage()

public setLanguage(TLanguage|null $language) : $this
Parameters
$language : TLanguage|null
Return values
$this

setSessionKey()

public setSessionKey(string $sessionKey) : $this
Parameters
$sessionKey : string
Return values
$this

setUpdateDatetime()

public setUpdateDatetime(DateTime|null $updateDatetime) : $this
Parameters
$updateDatetime : DateTime|null
Return values
$this

setUser()

public setUser(TUser|null $user) : $this
Parameters
$user : TUser|null
Return values
$this

setVouchers()

public setVouchers(Collection<int, TVoucher>|array<int, TVoucher> $vouchers) : $this
Parameters
$vouchers : Collection<int, TVoucher>|array<int, TVoucher>
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