MiniCartTrait
Mini cart signals: loading the panel content and editing rows from the header.
Behaves like the signals of the full cart (Cart) but ends differently:
- AJAX: redraws the badge (
cartCount) and the panel (cartDetail); the panel stays open becausecartWidget(and the dropdown toggle with it) is not redrawn. - Without JS: redirects to the cart. The panel never opens without JS, so this branch only guards a hand-built link.
NOTE: the signals need no CSRF protection of their own, because Nette 3.2 adds
#[Requires(sameOrigin: true)] to every handle*(). A foreign origin ends with a silent
redirect('this'), so debugging with curl needs the Sec-Fetch-Site: same-origin header.
Table of Contents
Methods
- handleDecrease() : void
- handleIncrease() : void
- handleLoadDetail() : void
- First panel open; the only request allowed to trigger the Api cart recalculation.
- handleRemove() : void
- guardEnabled() : void
- A disabled eshop (`catalog.only = 1`) has no cart or panel; the same gate as `addToCart!`.
- openDetail() : void
- Keeps the panel open and redrawn after each change.
Methods
handleDecrease()
public
handleDecrease(int $setId) : void
Parameters
- $setId : int
handleIncrease()
public
handleIncrease(int $setId) : void
Parameters
- $setId : int
handleLoadDetail()
First panel open; the only request allowed to trigger the Api cart recalculation.
public
handleLoadDetail() : void
handleRemove()
public
handleRemove(int $setId) : void
Parameters
- $setId : int
guardEnabled()
A disabled eshop (`catalog.only = 1`) has no cart or panel; the same gate as `addToCart!`.
private
guardEnabled() : void
openDetail()
Keeps the panel open and redrawn after each change.
private
openDetail() : void
A disappearing row is feedback enough, so the mini cart sends no flash message (the full cart does, because the whole page is redrawn after the redirect).