CoolCMS API

InitTrait

Prepares data for the badge and the mini cart ({@see \App\UI\Front\Eshop\Components\CartWidgetComponent\CartWidget}).

IMPORTANT: prepareWidget() reads only the session (quantity) and may run on every page, while prepareDetail() calls the Api cart recalculation and must run only after the panel is opened. Merging them would bring back a recalculation on every request.

Table of Contents

Constants

COUNT_DISPLAY_MAX  : int = 99
Highest quantity the badge prints as a number; above it the badge shows "99+".

Properties

$detailLoaded  : bool
Whether the panel content was loaded by `loadDetail!` ({@see MiniCartTrait}); until then a loading state is rendered.

Methods

prepareDetail()  : void
Called only with the panel open; the only place where the widget touches the Api.
prepareWidget()  : bool

Constants

COUNT_DISPLAY_MAX

Highest quantity the badge prints as a number; above it the badge shows "99+".

private int COUNT_DISPLAY_MAX = 99

The badge is two characters wide and a four-digit count would stretch it across the header. The exact count is kept in data-cart-count (read by JS) and in the screen reader label.

Properties

$detailLoaded

Whether the panel content was loaded by `loadDetail!` ({@see MiniCartTrait}); until then a loading state is rendered.

private bool $detailLoaded = false

Methods

prepareDetail()

Called only with the panel open; the only place where the widget touches the Api.

private prepareDetail() : void

prepareWidget()

private prepareWidget() : bool
Return values
bool —

whether the eshop is enabled (catalog.only = 0); with false nothing is rendered

On this page

Search results