Skip to content

Adds Order notices for admins#4315

Merged
lukeholder merged 12 commits into
5.7from
feature/5.x-order-admin-notices
Jun 17, 2026
Merged

Adds Order notices for admins#4315
lukeholder merged 12 commits into
5.7from
feature/5.x-order-admin-notices

Conversation

@lukeholder

@lukeholder lukeholder commented Jun 15, 2026

Copy link
Copy Markdown
Member

Description

Adds a noticeType field to OrderNotice with two values: 'customer' (default) and 'admin'.

Admin notices are hidden from customers and handled separately from regular notices:

  • getNotices() excludes admin notices; use getAdminNotices() to retrieve them
  • clearNotices() preserves admin notices by default; pass clearAdminNotices: true to clear all
  • hasAdminNotices() returns whether any admin notices exist
  • OrderQuery::hasAdminNotices() filters orders by the presence of admin notices
  • A new Has Admin Notices condition rule is available on the order index

In the CP order edit page, admin notices appear above customer notices in a red box with per-notice Clear buttons (only visible in edit mode). Customer notices are labelled "Customer Notices" and retain their existing Clear notices button (also edit-mode only).

A migration adds the noticeType column to commerce_ordernotices (defaulting to 'customer').

CleanShot 2026-06-15 at 16 48 13@2x

Built-in admin notices

Commerce adds admin notices automatically in the following scenarios during order completion:

  • Discount usage limit exceeded — when a discount's total usage limit has been surpassed (e.g. due to concurrent orders racing past the limit)
  • Coupon usage limit exceeded — when a coupon's max uses has been surpassed
  • Inventory below zero — when available inventory for a purchasable drops below zero after stock is committed, provided the purchasable does not allow out-of-stock purchases

@lukeholder lukeholder changed the title Feature/5.x order admin notices Adds Order notices for admins Jun 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

The CP UI introduces avoidable layout whitespace when no notices exist, and the CP save endpoint should enforce noticeType semantics for customer notices to keep the API contract unambiguous.

Pull request overview

This PR adds support for admin-only order notices alongside existing customer-facing notices, including persistence (noticeType column), new retrieval/clearing APIs, CP UI rendering, and order filtering via a new condition rule.

Changes:

  • Introduces OrderNotice::$noticeType (customer/admin) with DB schema updates and record/model wiring.
  • Adds APIs and query/condition support for admin notices (getAdminNotices(), hasAdminNotices(), OrderQuery::hasAdminNotices() + condition rule).
  • Updates the CP order edit UI to display admin notices separately and updates unit tests accordingly.
File summaries
File Description
tests/unit/elements/order/OrderNoticesTest.php Adds/updates unit tests validating admin notice behavior (hidden by default, retrieval, clearing).
src/web/assets/statwidgets/dist/CommerceChart.js.map Rebuilt asset sourcemap (includes updated comment in bundled sources).
src/web/assets/commerceui/src/js/order/helpers/utils.js Includes adminNotices in draft-building helper data.
src/web/assets/commerceui/src/js/order/apps/OrderNotices.vue Renders admin notices separately in the CP order UI and adds related styling/controls.
src/web/assets/commerceui/dist/css/order.css.map Rebuilt CSS sourcemap for order UI styles.
src/web/assets/commerceui/dist/css/order.css Rebuilt compiled CSS including admin notices styling.
src/web/assets/commercecp/dist/css/commercecp.css.map Rebuilt CP CSS sourcemap (contains updated bundled sources).
src/services/OrderNotices.php Ensures noticeType is selected when eager-loading notices.
src/records/OrderNotice.php Documents the new noticeType column on the record.
src/models/OrderNotice.php Adds notice type constants, model property default, and validation rule.
src/migrations/m260615_000000_add_notice_type_to_order_notices.php Adds the noticeType column (default customer) with safeUp/safeDown.
src/migrations/Install.php Adds noticeType to the install schema for commerce_ordernotices.
src/elements/traits/OrderNoticesTrait.php Implements customer vs admin filtering, new getters, and updated clearing behavior.
src/elements/traits/OrderElementTrait.php Adds table attribute HTML rendering for hasAdminNotices.
src/elements/Order.php Exposes adminNotices as an extra field and persists noticeType when saving notices.
src/elements/db/OrderQuery.php Adds hasAdminNotices param + SQL exists filter for admin notices.
src/elements/conditions/orders/OrderCondition.php Registers the new “Has Admin Notices” condition rule.
src/elements/conditions/orders/HasAdminNoticesConditionRule.php Implements the new condition rule hooking into OrderQuery::hasAdminNotices().
src/controllers/OrdersController.php Includes adminNotices in order serialization and updates CP save logic to handle both notice sets.
CHANGELOG-WIP.md Documents the new admin notice functionality and APIs.

Copilot's findings

  • Files reviewed: 16/22 changed files
  • Comments generated: 3

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<template>
<div v-if="showNotices">
<div class="meta read-only warning">
<div class="order-notices-wrapper">
Comment thread src/controllers/OrdersController.php
Comment thread src/elements/db/OrderQuery.php Outdated
lukeholder and others added 3 commits June 17, 2026 20:51
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lukeholder lukeholder merged commit 31be067 into 5.7 Jun 17, 2026
1 of 4 checks passed
@lukeholder lukeholder deleted the feature/5.x-order-admin-notices branch June 17, 2026 12:54
@lukeholder lukeholder mentioned this pull request Jun 17, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants