Notices::get_notices_template()publicWC 1.0

Replaces core notice templates with those from blocks.

The new notice templates match block components with matching icons and styling. The differences are:

  1. Core has notices for info, success, and error notices, blocks has notices for info, success, error, warning, and a default notice type.
  2. The block notices use different CSS classes to the core notices. Core uses woocommerce-message, is-info and is-error classes, blocks uses wc-block-components-notice-banner is-error, wc-block-components-notice-banner is-info, and wc-block-components-notice-banner is-success.
  3. The markup of the notices is different, with the block notices using SVG icons and a slightly different structure to accommodate this.

Method of the class: Notices{}

No Hooks.




$Notices = new Notices();
$Notices->get_notices_template( $template, $template_name, $args, $template_path, $default_path );
$template(string) (required)
Located template path.
$template_name(string) (required)
Template name.
$args(array) (required)
Template arguments.
$template_path(string) (required)
Template path.
$default_path(string) (required)
Default path.

Notices::get_notices_template() code WC 9.0.1

public function get_notices_template( $template, $template_name, $args, $template_path, $default_path ) {
	$directory = get_stylesheet_directory();
	$file      = $directory . '/woocommerce/' . $template_name;
	if ( file_exists( $file ) ) {
		return $file;

	if ( in_array( $template_name, $this->notice_templates, true ) ) {
		$template = $this->package->get_path( 'templates/block-' . $template_name );
		wp_enqueue_style( 'wc-blocks-style' );

	return $template;