CoolCMS API

DisplayRegionResolver
in package

FinalYes

Single source of currency and VAT for displaying prices on the website: the payment region.

Catalog, cart and order show prices in the currency of the payment region, not the localization currency. The region is chosen in this order:

  1. region chosen by the customer in the order (checkout, cart session),
  2. region of the localization (/en/ gives "EU" and EUR),
  3. first usable default region (is_default),
  4. first usable region at all.

Usable means an active region with an active, non-internal currency. A region with a disabled or internal currency (credits) would show prices that cannot be paid, so it is skipped.

The class is pure (no DI, no DB); contexts fill it from presenters and checkout. Covered by tests/Unit/Core/DisplayRegionResolverTest.php.

Table of Contents

Methods

currencyOf()  : Currency|null
differsFromLocalization()  : bool
Whether the order region differs from the localization region. The customer then has to get a message that the cart was recalculated (another currency or another VAT).
indexCurrencies()  : array<int, Currency>
Currencies indexed by id (the `findAll()` input is a list).
isUsable()  : bool
resolve()  : PaymentRegion|null

Methods

differsFromLocalization()

Whether the order region differs from the localization region. The customer then has to get a message that the cart was recalculated (another currency or another VAT).

public static differsFromLocalization(PaymentRegion|null $effective, PaymentRegion|null $localizationRegion) : bool
Parameters
$effective : PaymentRegion|null
$localizationRegion : PaymentRegion|null
Return values
bool

indexCurrencies()

Currencies indexed by id (the `findAll()` input is a list).

public static indexCurrencies(iterable<string|int, mixed> $currencies) : array<int, Currency>
Parameters
$currencies : iterable<string|int, mixed>
Return values
array<int, Currency>

resolve()

public static resolve(iterable<string|int, mixed> $regions, array<int, Currency> $currencies, int|null $requestedRegionId, int|null $localizationRegionId) : PaymentRegion|null
Parameters
$regions : iterable<string|int, mixed>

payment regions (other values are ignored)

$currencies : array<int, Currency>

currencies by id

$requestedRegionId : int|null
$localizationRegionId : int|null
Return values
PaymentRegion|null
On this page

Search results