CoolCMS API

CheckoutRegionTrait

Resolves the payment region of the cart and order, shared by the full cart, the mini cart and the order steps so that all three compute in the same currency and VAT.

The default is the localization region (CurrencyContext::getLocalizationPaymentRegion()). The customer can switch it in order step 1 (for example /en/ to the Czech Republic means the Czech koruna). The choice is kept in the unfinished checkout together with the localization it was made on; after the website language is switched it is dropped and the localization region applies again, otherwise /cs/ would unexpectedly compute in euros. The catalog ignores the choice and always shows the localization region.

The trait expects $cart (CartManager) and contexts from BaseComponent.

Table of Contents

Constants

CHECKOUT_REGION_KEY  : string = 'paymentRegionId'
CHECKOUT_REGION_LOCALIZATION_KEY  : string = 'paymentRegionLocalizationId'

Properties

$checkoutRegionCache  : PaymentRegion|null
$checkoutRegionResolved  : bool

Methods

getCheckoutCurrency()  : Currency|null
Exposes the order currency for the cart and order presenter, which passes it as the page currency (`CurrencyContext::setPageCurrency()`) so that front end JS formats in the same currency.
checkoutCurrency()  : Currency|null
Returns the cart or order currency, the currency of the region from {@see checkoutRegion()}.
checkoutRegion()  : PaymentRegion|null
Returns the region by which the cart and order are computed.
checkoutRegionName()  : string
Returns the region name in the website language (fallback `#id`).
checkoutRegionNotice()  : array{region: string, currency: string, currencyChanged: bool}|null
Returns the recalculation notice data; null when the cart computes in the localization region, otherwise the chosen region name and currency (the template builds a sentence from them).
resetCheckoutRegion()  : void
Forgets the resolved region (after a new choice is stored within the same request).
checkoutCurrencies()  : array<int, Currency>
requestedCheckoutRegionId()  : int|null

Constants

CHECKOUT_REGION_LOCALIZATION_KEY

public string CHECKOUT_REGION_LOCALIZATION_KEY = 'paymentRegionLocalizationId'

Properties

Methods

getCheckoutCurrency()

Exposes the order currency for the cart and order presenter, which passes it as the page currency (`CurrencyContext::setPageCurrency()`) so that front end JS formats in the same currency.

public getCheckoutCurrency() : Currency|null
Return values
Currency|null

checkoutCurrency()

Returns the cart or order currency, the currency of the region from {@see checkoutRegion()}.

protected checkoutCurrency() : Currency|null
Return values
Currency|null

checkoutRegionName()

Returns the region name in the website language (fallback `#id`).

protected checkoutRegionName(PaymentRegion|null $region) : string
Parameters
$region : PaymentRegion|null
Return values
string

checkoutRegionNotice()

Returns the recalculation notice data; null when the cart computes in the localization region, otherwise the chosen region name and currency (the template builds a sentence from them).

protected checkoutRegionNotice() : array{region: string, currency: string, currencyChanged: bool}|null
Return values
array{region: string, currency: string, currencyChanged: bool}|null

resetCheckoutRegion()

Forgets the resolved region (after a new choice is stored within the same request).

protected resetCheckoutRegion() : void

requestedCheckoutRegionId()

private requestedCheckoutRegionId() : int|null
Return values
int|null
On this page

Search results