Skip to content

OrderNoticesTrait ​

Type
Trait
Namespace
craft\commerce\elements\traits
Implemented by
craft\commerce\elements\Order
Since
3.3

Adds order notice getters and setters.

View source

Public Methods ​

MethodDescription
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

View source

Arguments ​

  • $notice

addNotices() ​

Since
3.3

Adds a list of notices.

View source

Arguments ​

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.

View source

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.

View source

Arguments ​

Returns ​

craft\commerce\models\OrderNotice[]

getFirstNotice() ​

Since
3.3

Returns the first non-admin notice matching the specified type or attribute.

View source

Arguments ​

getNotices() ​

Since
3.3

Returns non-admin notices. Admin notices are excluded by default.

View source

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.

View source

hasNotices() ​

Since
3.3

Returns a value indicating whether there are any non-admin notices.

View source

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.