CoolCMS API

PaymentMethodFormTrait uses trait:short

Edit/add form of a payment method (checkout code list): VAT, payment gateway, proforma, availability and multilingual texts.

Availability and surcharge per shipping are not edited here. The matrix PaymentMethodPrice is keyed by (shipperTariff x paymentMethod x currency) and edited in the tariff form as the owned collection ShipperTariff::$paymentPrices. PaymentMethod has no price collection, so this form cannot overwrite the matrix by accident.

Table of Contents

Constants

SUPPLY_KIND_SETTING_MODULE_INVOICER  : mixed = 7
Module "invoicer" in the settings table (`cms_system_settings.module`); holds the portal `sellerId`.

Properties

$supplyKindFieldsManager  : SupplyKindManager
$supplyKindFieldsSellerManager  : SellerManager
$supplyKindFieldsVatRateManager  : VatRateManager

Methods

addSupplyKindSelect()  : SelectBox
Adds the supply kind select. The options are database names, so the select translator is off and the prompt is translated here. IMPORTANT: the label must stay a translation key (`BaseControl::getLabel()` takes the translator from the form); a translated label would be translated twice.
buildSupplyKindRegionVatMaps()  : array<int, array<int, string>>
Returns the rate map for the helper field "price with VAT": `regionId => supplyKindId => percent` (valid today).
buildSupplyKindVatMapAttributes()  : array<int, array{json: string, map: array}>
Returns the same as {@see buildSupplyKindRegionVatMaps()} plus JSON for the `data-price-vat-map` attribute of the region matrix (keys as strings, because JS reads `map[select.value]`).
createComponentEditForm()  : Form
getSupplyKindOptions()  : array<int, string>
Returns active supply kinds as `id => name` in the admin language.
supplyKindIdValue()  : int|null
Converts the supply kind select value to an id, or null for the empty prompt.
addPaymentMethodMainFields()  : void
addPaymentMethodTranslationFields()  : void
buildPaymentMethodEntity()  : PaymentMethod
loadPaymentMethodSelectData()  : void
Loads the form axes (VAT rates, payment gateways) once per request. Percentages and the gateway script name are ready data, not keys, hence `NotTranslate` (otherwise the form's domain translator looks them up as keys).
resolveSupplyKindSellerCountryCode()  : string|null
Returns the portal seller country (`7/invoice.default.sellerId`) as a fallback for a region without a country; null when the seller is not found.
savePaymentMethodForm()  : bool
setPaymentMethodFormDefaults()  : void

Constants

SUPPLY_KIND_SETTING_MODULE_INVOICER

Module "invoicer" in the settings table (`cms_system_settings.module`); holds the portal `sellerId`.

private mixed SUPPLY_KIND_SETTING_MODULE_INVOICER = 7

Properties

Methods

addSupplyKindSelect()

Adds the supply kind select. The options are database names, so the select translator is off and the prompt is translated here. IMPORTANT: the label must stay a translation key (`BaseControl::getLabel()` takes the translator from the form); a translated label would be translated twice.

protected addSupplyKindSelect(Form $form, string $name, string $labelKey, string|null $promptKey[, string|null $descriptionKey = null ][, int|null $currentId = null ]) : SelectBox
Parameters
$form : Form
$name : string
$labelKey : string
$promptKey : string|null

null = no prompt (the field is required, the first or current kind is preselected)

$descriptionKey : string|null = null
$currentId : int|null = null
Return values
SelectBox

buildSupplyKindRegionVatMaps()

Returns the rate map for the helper field "price with VAT": `regionId => supplyKindId => percent` (valid today).

protected buildSupplyKindRegionVatMaps(iterable<string|int, PaymentRegion> $regions) : array<int, array<int, string>>
Parameters
$regions : iterable<string|int, PaymentRegion>
Return values
array<int, array<int, string>>

buildSupplyKindVatMapAttributes()

Returns the same as {@see buildSupplyKindRegionVatMaps()} plus JSON for the `data-price-vat-map` attribute of the region matrix (keys as strings, because JS reads `map[select.value]`).

protected buildSupplyKindVatMapAttributes(iterable<string|int, PaymentRegion> $regions) : array<int, array{json: string, map: array}>

For the template: regionId => {json, map}.

Parameters
$regions : iterable<string|int, PaymentRegion>
Return values
array<int, array{json: string, map: array}>

getSupplyKindOptions()

Returns active supply kinds as `id => name` in the admin language.

protected getSupplyKindOptions([int|null $keepId = null ]) : array<int, string>
Parameters
$keepId : int|null = null
Return values
array<int, string>

supplyKindIdValue()

Converts the supply kind select value to an id, or null for the empty prompt.

protected supplyKindIdValue(mixed $value) : int|null
Parameters
$value : mixed
Return values
int|null

loadPaymentMethodSelectData()

Loads the form axes (VAT rates, payment gateways) once per request. Percentages and the gateway script name are ready data, not keys, hence `NotTranslate` (otherwise the form's domain translator looks them up as keys).

private loadPaymentMethodSelectData() : void

resolveSupplyKindSellerCountryCode()

Returns the portal seller country (`7/invoice.default.sellerId`) as a fallback for a region without a country; null when the seller is not found.

private resolveSupplyKindSellerCountryCode() : string|null
Return values
string|null

savePaymentMethodForm()

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

Search results