Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
Renderer::render_interactivity_notices_region
Render interactivity API powered notices that can be added client-side. This reuses classes from the woocommerce/store-notices block to ensure style consistency.
Method of the class: Renderer{}
No Hooks.
Returns
String. The rendered store notices HTML.
Usage
// protected - for code of main (parent) or child class $result = $this->render_interactivity_notices_region();
Renderer::render_interactivity_notices_region() Renderer::render interactivity notices region code WC 10.6.2
<?php
protected function render_interactivity_notices_region() {
wp_interactivity_state(
'woocommerce/store-notices',
array(
'notices' => array(),
)
);
ob_start();
?>
<div data-wp-interactive="woocommerce/store-notices" class="wc-block-components-notices alignwide">
<template data-wp-each--notice="state.notices" data-wp-each-key="context.notice.id">
<div
class="wc-block-components-notice-banner"
data-wp-init="callbacks.scrollIntoView"
data-wp-class--is-error="state.isError"
data-wp-class--is-success="state.isSuccess"
data-wp-class--is-info="state.isInfo"
data-wp-class--is-dismissible="context.notice.dismissible"
data-wp-bind--role="state.role"
data-wp-watch="callbacks.injectIcon"
>
<div class="wc-block-components-notice-banner__content">
<span data-wp-init="callbacks.renderNoticeContent" aria-live="assertive" aria-atomic="true"></span>
</div>
<button
data-wp-bind--hidden="!context.notice.dismissible"
class="wc-block-components-button wp-element-button wc-block-components-notice-banner__dismiss contained"
aria-label="<?php esc_attr_e( 'Dismiss this notice', 'woocommerce' ); ?>"
data-wp-on--click="actions.removeNotice"
>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z" />
</svg>
</button>
</div>
</template>
</div>
<?php
return ob_get_clean();
}