OrderNoticesTrait ​
- Type
- Trait
- Namespace
- craft\commerce\elements\traits
- Implemented by
- craft\commerce\elements\Order
- Since
- 3.3
Adds order notice getters and setters.
Public Methods ​
| Method | Description |
|---|---|
| addNotice() | Adds a new notice |
| addNotices() | Adds a list of notices. |
| clearNotices() | Removes notices matching the given criteria, scoped to the specified notice types. |
| getAdminNotices() | Returns admin-only notices, optionally filtered by type and/or attribute. |
| getFirstNotice() | Returns the first non-admin notice matching the specified type or attribute. |
| getNotices() | Returns non-admin notices. Admin notices are excluded by default. |
| hasAdminNotices() | Returns whether there are any admin notices. |
| hasNotices() | Returns a value indicating whether there are any non-admin notices. |
addNotice() ​
- Since
- 3.3
Adds a new notice
Arguments ​
$notice
addNotices() ​
- Since
- 3.3
Adds a list of notices.
Arguments ​
$notices(craft\commerce\models\OrderNotice[]) – An array of notices.
clearNotices() ​
- Since
- 3.3
Removes notices matching the given criteria, scoped to the specified notice types.
By default only customer notices are cleared, preserving admin notices for backwards compatibility. Pass one or more {@see \craft\commerce\enums\OrderNoticeType} values to control which notice types are affected.
Arguments ​
$type(string, null) – Type name. Use null to remove notices for all types.$attribute(string, null) – Attribute name. Use null to remove notices for all attributes.$noticeTypes(\craft\commerce\enums\OrderNoticeType,\craft\commerce\enums\OrderNoticeType[], null) – Notice type(s) to clear. Defaults to customer notices only.
getAdminNotices() ​
- Since
- 5.x
Returns admin-only notices, optionally filtered by type and/or attribute.
Arguments ​
Returns ​
craft\commerce\models\OrderNotice[]
getFirstNotice() ​
- Since
- 3.3
Returns the first non-admin notice matching the specified type or attribute.
Arguments ​
getNotices() ​
- Since
- 3.3
Returns non-admin notices. Admin notices are excluded by default.
Arguments ​
$type(string, null) – Type name. Use null to retrieve notices for all types.$attribute(string, null) – Attribute name. Use null to retrieve notices for all attributes.
Returns ​
craft\commerce\models\OrderNotice[] – Notices for all types or the specified type / attribute. Empty array is returned if no notice.
hasAdminNotices() ​
- Since
- 5.x
Returns whether there are any admin notices.
hasNotices() ​
- Since
- 3.3
Returns a value indicating whether there are any non-admin notices.
Arguments ​
$type(string, null) – Type name. Use null to check all types.$attribute(string, null) – Attribute name. Use null to check all attributes.
Returns ​
boolean – Whether there is any notices.