CoolCMS API

ShipperTariffPrice extends BaseEntity
in package
implements IdentifiableInterface uses IdentifiableTrait

AbstractYes

Tariff price: an append-only time series per weight interval × currency × validity date (`dateFrom`). Unlike {@see ProductSetFeePrice}/{@see ProductSetPrice} (composite PK without surrogate id, where `publishedTime` must be ORM `type: 'string'`), this entity keeps a surrogate auto-increment `id`, so `dateFrom` is not part of the Doctrine identifier and is a normal `type: 'datetime'` column. The property is `\DateTime`, not `\DateTimeImmutable`: the DBAL `datetime` type accepts only `\DateTime` (the immutable one needs `datetime_immutable`).

currencyId stays a scalar int (a price series axis, no JOIN needed), like ProductSetFeePrice::$currencyId and ProductSetPrice::$currencyId. Weights are decimal (not float) for exact string comparison on interval edges.

weightTo === null is a band without an upper bound ("from X kg up"), typically the last band. A generation may hold at most one such band and it must have the highest weightFrom of the generation, otherwise the open band would overlap the ones above it. Only the admin tariff form enforces this (the Api manager does not), not the database: a mysql unique index treats each null as distinct, so a unique over (tariff, currency, date_from, weight_from, weight_to) lets two open bands through. Consumers of getWeightTo()/getWeightToAsFloat() must treat null as infinity; in sql write (weight_to is null or weight_to >= :w).

active is the per currency × band checkbox. ShippingPriceResolver does not filter it in sql: when the newest matching row is active = 0, the tariff is not offered for that weight and currency (no fallback to an older generation). The row and its history stay in the database, like available in PaymentMethodPrice. It is not the same as deleting the band.

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

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

$active  : bool
$currencyId  : int|null
$dateFrom  : DateTime|null
$freeFrom  : string|null
$id  : int|null
$price  : string
$tariff  : TShipperTariff|null
$vat  : TVat|null
$weightFrom  : string
$weightTo  : string|null

Methods

__construct()  : mixed
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
getActive()  : bool
getAllTraits()  : array<string, string>
Returns all traits the class uses, including those used by parent classes and nested traits.
getCurrencyId()  : int|null
getDateFrom()  : DateTime|null
getFreeFrom()  : string|null
getFreeFromAsFloat()  : float|null
getId()  : int|null
getPrice()  : string
getPriceAsFloat()  : float
getTariff()  : TShipperTariff|null
getVat()  : TVat|null
getWeightFrom()  : string
getWeightFromAsFloat()  : float
getWeightTo()  : string|null
getWeightToAsFloat()  : float|null
isActive()  : bool
isPersisted()  : bool
setActive()  : $this
setCurrencyId()  : $this
setDateFrom()  : $this
setFreeFrom()  : $this
setId()  : $this
setPrice()  : $this
setTariff()  : $this
setVat()  : $this
setWeightFrom()  : $this
setWeightTo()  : $this
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$active

protected bool $active = true
Attributes
#[Column]
$name: 'active'
$type: 'boolean'
$options: ['default' => true]

$currencyId

protected int|null $currencyId = null
Attributes
#[Column]
$name: 'cms_system_currencies_currency_id'
$type: 'integer'
$options: ['unsigned' => true]

$dateFrom

protected DateTime|null $dateFrom = null
Attributes
#[Column]
$name: 'date_from'
$type: 'datetime'

$freeFrom

protected string|null $freeFrom = null
Attributes
#[Column]
$name: 'free_from'
$type: 'decimal'
$precision: 10
$scale: 3
$nullable: true

$id

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

$price

protected string $price = '0.000'
Attributes
#[Column]
$name: 'price'
$type: 'decimal'
$precision: 10
$scale: 3

$weightFrom

protected string $weightFrom = '0.000'
Attributes
#[Column]
$name: 'weight_from'
$type: 'decimal'
$precision: 10
$scale: 3
$options: ['unsigned' => true]

$weightTo

protected string|null $weightTo = null
Attributes
#[Column]
$name: 'weight_to'
$type: 'decimal'
$precision: 10
$scale: 3
$nullable: true
$options: ['unsigned' => true]

Methods

__construct()

public __construct([int|null $id = null ][, mixed $tariff = null ][, int|null $currencyId = null ][, mixed $vat = null ][, DateTime|null $dateFrom = null ][, string $weightFrom = '0.000' ][, string|null $weightTo = null ][, string $price = '0.000' ][, bool $active = true ][, string|null $freeFrom = null ]) : mixed
Parameters
$id : int|null = null
$tariff : mixed = null
$currencyId : int|null = null
$vat : mixed = null
$dateFrom : DateTime|null = null
$weightFrom : string = '0.000'
$weightTo : string|null = null
$price : string = '0.000'
$active : bool = true
$freeFrom : string|null = null

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>

getFreeFromAsFloat()

public getFreeFromAsFloat() : float|null
Return values
float|null

getTariff()

public getTariff() : TShipperTariff|null
Return values
TShipperTariff|null

getWeightFromAsFloat()

public getWeightFromAsFloat() : float
Return values
float

getWeightToAsFloat()

public getWeightToAsFloat() : float|null
Return values
float|null

setActive()

public setActive(bool $active) : $this
Parameters
$active : bool
Return values
$this

setCurrencyId()

public setCurrencyId(int|null $currencyId) : $this
Parameters
$currencyId : int|null
Return values
$this

setDateFrom()

public setDateFrom(DateTime|null $dateFrom) : $this
Parameters
$dateFrom : DateTime|null
Return values
$this

setFreeFrom()

public setFreeFrom(string|null $freeFrom) : $this
Parameters
$freeFrom : string|null
Return values
$this

setId()

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

setPrice()

public setPrice(string $price) : $this
Parameters
$price : string
Return values
$this

setTariff()

public setTariff(TShipperTariff|null $tariff) : $this
Parameters
$tariff : TShipperTariff|null
Return values
$this

setVat()

public setVat(TVat|null $vat) : $this
Parameters
$vat : TVat|null
Return values
$this

setWeightFrom()

public setWeightFrom(string $weightFrom) : $this
Parameters
$weightFrom : string
Return values
$this

setWeightTo()

public setWeightTo(string|null $weightTo) : $this
Parameters
$weightTo : string|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