Adds Order notices for admins#4315
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
⚠️ 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"> |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
noticeTypefield toOrderNoticewith two values:'customer'(default) and'admin'.Admin notices are hidden from customers and handled separately from regular notices:
getNotices()excludes admin notices; usegetAdminNotices()to retrieve themclearNotices()preserves admin notices by default; passclearAdminNotices: trueto clear allhasAdminNotices()returns whether any admin notices existOrderQuery::hasAdminNotices()filters orders by the presence of admin noticesIn 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
noticeTypecolumn tocommerce_ordernotices(defaulting to'customer').Built-in admin notices
Commerce adds admin notices automatically in the following scenarios during order completion: