CoolCMS API

ProductSetFeeFormTrait

Edit/add form of a fee: multilingual texts (name/description), the fee type (select, {@see ProductSetFeeType}) and a price multiplier per currency ({@see ProductSetFeePrice}, an append-only time series like {@see \App\UI\Admin\Eshop\Models\Entities\ProductSetPrice}). Prices are not a dynamic `Multiplier`: the axis (active System currencies) is small and fixed, so rows are generated by a fixed loop (like `Admin\Bazaar\CategoryFormTrait::addCategoryPriceMatrix`).

IMPORTANT: append-only semantics. Existing history rows are always sent to the saved collection unchanged (see buildProductSetFeePrices), because the owned collection is a full replace (orphanRemoval) in the object-graph save and omitting an old price would delete it irrecoverably. A new price is created only when the entered value (price or VAT) differs from the currently valid one (the latest publishedDatetime <= NOW()); it is saved as a new row with publishedDatetime = NOW() and the old rows stay unchanged (history).

Table of Contents

Methods

createComponentEditForm()  : Form
addProductSetFeePriceFields()  : void
One row (price + VAT) per active currency; fixed axis {@see \App\UI\Admin\Eshop\Presenters\ProductSetFeePresenter::$productSetFeeCurrencies}.
addProductSetFeeTranslationFields()  : void
Multilingual fields: one set per language (`<field>_<langId>`), active per checkbox.
addProductSetFeeTypeField()  : void
buildProductSetFeeEntity()  : ProductSetFee
buildProductSetFeePrices()  : ArrayCollection<int, ProductSetFeePrice>
Collection of prices to save: all existing rows (history, unchanged) + new rows only for currencies where the price/VAT differs from the currently valid one.
currentProductSetFeePriceFor()  : ProductSetFeePrice|null
Latest valid price for a currency (`publishedDatetime <= $now`, maximum) from the existing rows.
loadProductSetFeeSelectData()  : void
Loads the form axes (active currencies, VAT rates, fee types) once per request; called from `createComponentEditForm` before building fields and defaults.
saveProductSetFeeForm()  : bool
setProductSetFeeFormDefaults()  : void

Methods

addProductSetFeePriceFields()

One row (price + VAT) per active currency; fixed axis {@see \App\UI\Admin\Eshop\Presenters\ProductSetFeePresenter::$productSetFeeCurrencies}.

private addProductSetFeePriceFields(Form $form) : void
Parameters
$form : Form

addProductSetFeeTranslationFields()

Multilingual fields: one set per language (`<field>_<langId>`), active per checkbox.

private addProductSetFeeTranslationFields(Form $form) : void
Parameters
$form : Form

buildProductSetFeePrices()

Collection of prices to save: all existing rows (history, unchanged) + new rows only for currencies where the price/VAT differs from the currently valid one.

private buildProductSetFeePrices(ArrayHash<string|int, mixed> $values, ProductSetFee $fee) : ArrayCollection<int, ProductSetFeePrice>
Parameters
$values : ArrayHash<string|int, mixed>
$fee : ProductSetFee
Return values
ArrayCollection<int, ProductSetFeePrice>

currentProductSetFeePriceFor()

Latest valid price for a currency (`publishedDatetime <= $now`, maximum) from the existing rows.

private currentProductSetFeePriceFor(ProductSetFee $fee, int $currencyId, string $now) : ProductSetFeePrice|null

publishedDatetime is an ORM string (Y-m-d H:i:s), so lexicographic comparison equals chronological.

Parameters
$fee : ProductSetFee
$currencyId : int
$now : string
Return values
ProductSetFeePrice|null

loadProductSetFeeSelectData()

Loads the form axes (active currencies, VAT rates, fee types) once per request; called from `createComponentEditForm` before building fields and defaults.

private loadProductSetFeeSelectData() : void

saveProductSetFeeForm()

private saveProductSetFeeForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
$values : ArrayHash<string|int, mixed>
Return values
bool
On this page

Search results