Dashboard alerts
The strip at the top of the store admin that says what needs attention, and the two actions on it.
Four checks ship with KahunaCart and an add-on can register more. The read answers every alert this user should see, loudest first. See Orders and the admin.
What needs the merchant's attention
/api/v1/kahunacart/alerts
What needs attention right now, for the calling user: orders waiting to be paid, background jobs that are not running, stock running out, a report rollup that should be rebuilt, and anything other plugins have registered. Each alert has a severity, a headline and a sentence under it as language keys with their arguments, and the buttons a merchant can press. Alerts this user has hidden are left out unless you set dismissed.
Parameters
| Name | Type | Description |
|---|---|---|
| dismissed optional | string |
Include the ones this user has put away
One of:
1 |
Put a dashboard alert away
/api/v1/kahunacart/alerts/{id}/dismiss
Hide one alert for the calling user. How long it stays hidden is up to the alert: low stock comes back the next day, the rest come back as soon as the problem is still there. Send restore: true to show it again.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | string | The alert id, e.g. low_stock |
| restore optional | boolean |
Put it back instead of putting it away
Default:
false |
Re-run every dashboard check
/api/v1/kahunacart/alerts/rebuild
Clear every cached alert check so they all run again on the next read. Use this after fixing whatever an alert was reporting, instead of waiting for its next scheduled check.
The shipped checks are unpaid_orders (completed orders still waiting to be paid, re-run on every read), jobs_stale (the queue is not draining, or jobs are failing, re-run after 60 seconds), low_stock (products at or below the threshold, re-run after 5 minutes) and reports_rollup_stale (the rollup predates cost of goods, so margin is scanned for, re-run after an hour). An alert comes back as its id, its severity of info, warning or error, a headline and a sentence under it, its actions, the raw data the check produced, and whether this user has hidden it. The headline and the sentence are language keys plus the arguments to fill in rather than finished text, so an add-on's alert reads like one of KahunaCart's own.
A check does not run again before its interval is up, so six screens asking within a minute cost one check. alerts.min_recheck_seconds puts a floor under every alert's own interval, an add-on's included, and alerts.enabled: false runs no checks at all rather than running them and drawing nothing. One check erroring costs that one alert and the dashboard still draws.
Dismissing hides an alert for one user and never for everyone, because the store either has the problem or it does not, whoever is looking. How long a dismissal lasts is the alert's own decision: low stock comes back tomorrow, the other three have no window. An alert nobody registered answers 404 rather than storing a dismissal against a name that means nothing.
Reading and dismissing need kahunacart.orders.view. Rebuilding needs kahunacart.settings, because clearing every cached check affects the whole store rather than one person's list. An add-on registers its own check on onKahunaCartRegisterDashboardAlerts.