Automattic\WooCommerce\Internal\ShopperLists

ShopperListRenderer::render_empty_statepublic staticWC 1.0

Empty-state <li> that the block toggles on once state.isEmpty flips. $start_hidden = true makes SSR ship with hidden so the message doesn't flash for shoppers whose list is being populated client-side. $start_hidden = false is for blocks (e.g. Wishlist) where the message should show on first paint when the list is empty.

Method of the class: ShopperListRenderer{}

No Hooks.

Returns

String.

Usage

$result = ShopperListRenderer::render_empty_state( $message, $css_class, $start_hidden ): string;
$message(string) (required)
Visible empty-state message.
$css_class(string) (required)
Class attribute for the <li>.
$start_hidden(true|false)
Whether the <li> should be hidden on first paint.
Default: true

ShopperListRenderer::render_empty_state() code WC 10.9.1

public static function render_empty_state( string $message, string $css_class, bool $start_hidden = true ): string {
	return sprintf(
		'<li class="%1$s" data-wp-bind--hidden="!state.isEmpty"%2$s>%3$s</li>',
		esc_attr( $css_class ),
		$start_hidden ? ' hidden' : '',
		esc_html( $message )
	);
}