CheckoutErrorMessage
in package
Builds the customer message for a failed `api/eshop/order/checkout` response, in the front end language.
Besides message (a Czech sentence for log and admin) the Api returns a machine-readable
errorCode, for voucher codes also reason + params (VoucherRedemptionService) and for
insufficient stock shortItems. Printing message directly would show Czech sentences in
the English and Slovak cart/checkout.
The result is a translation key + parameters, not final text: the component translates it
with its translator or passes it to a flash message as
Contributte\Translation\Wrappers\Message. An unknown code falls back to a generic message;
technical detail does not belong to the customer. Pure helper without I/O, hence static
(like PriceDisplayHelper).
Table of Contents
Constants
- KEY_PREFIX : string = 'front.eshop.checkoutErrors.'
- CODES : array<string|int, mixed> = [ 'emptyCart', 'itemsInvalid', 'shippingInvalid...
- Failure codes with their own message (without parameters unless noted otherwise).
- VOUCHER_REASONS : array<string|int, mixed> = ['voucherLimit', 'voucherNoCurrency', 'voucherD...
- Reasons for rejecting a voucher code (`VoucherRedemptionService::reason()`).
Methods
-
resolve()
: array{key: string, params: array
} - plainAmount() : string
- `1000.000` becomes `1000`, `99.500` becomes `99.5`: decimal(10,3) from the Api without trailing zeros.
-
voucher()
: array{key: string, params: array
}
Constants
KEY_PREFIX
public
string
KEY_PREFIX
= 'front.eshop.checkoutErrors.'
CODES
Failure codes with their own message (without parameters unless noted otherwise).
private
array<string|int, mixed>
CODES
= [
'emptyCart',
'itemsInvalid',
'shippingInvalid',
'shippingRequired',
'paymentInvalid',
'paymentRequired',
'pickupPointRequired',
'sellerRequired',
// Set without a price in the cart currency (for example priced only in `CZK` while the cart on `/sk/` is in `EUR`).
'noPriceInCurrency',
// The region chosen in the order is disabled or has no usable currency.
'paymentRegionInvalid',
// VAT engine returned no usable treatment (missing seller status, rate...); the order is
// rather not created than created with a silent zero tax.
'taxUnavailable',
// Stock sold out between the strict gate and the reservation; order withdrawn.
'stockReserveFailed',
// The region of the chosen tariff does not deliver to the address country.
'shippingCountryMismatch',
]
VOUCHER_REASONS
Reasons for rejecting a voucher code (`VoucherRedemptionService::reason()`).
private
array<string|int, mixed>
VOUCHER_REASONS
= ['voucherLimit', 'voucherNoCurrency', 'voucherDuplicate', 'voucherNotFound', 'voucherNotActive', 'voucherExhausted', 'voucherCurrency', 'voucherMinTotal', 'voucherMaxTotal']
Methods
resolve()
public
static resolve(array<string, mixed> $result[, string $currency = '' ]) : array{key: string, params: array}
Parameters
- $result : array<string, mixed>
-
checkout response (
success: false) - $currency : string = ''
-
cart currency abbreviation for amounts in messages (for example the koruna or euro sign)
Return values
array{key: string, params: arrayplainAmount()
`1000.000` becomes `1000`, `99.500` becomes `99.5`: decimal(10,3) from the Api without trailing zeros.
private
static plainAmount(string $amount) : string
Parameters
- $amount : string
Return values
stringvoucher()
private
static voucher(array<string, mixed> $result, string $currency) : array{key: string, params: array}
Parameters
- $result : array<string, mixed>
- $currency : string