Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
Renderer::render_empty_placeholder
Render an empty placeholder for cart-referencing collections. This allows the Interactivity Router to find and replace the content when the cart changes.
Метод класса: Renderer{}
Хуков нет.
Возвращает
string. Empty placeholder HTML with router-region and watch attributes.
Использование
// private - только в коде основоного (родительского) класса $result = $this->render_empty_placeholder();
Код Renderer::render_empty_placeholder() Renderer::render empty placeholder WC 11.3.0
<?php
private function render_empty_placeholder() {
$query_id = $this->parsed_block['attrs']['queryId'] ?? null;
if ( null === $query_id ) {
return '';
}
wp_enqueue_script_module( 'woocommerce/product-collection' );
wp_enqueue_script_module( 'woocommerce/product-collection-cart-reference' );
ob_start();
?>
<div
class="wp-block-woocommerce-product-collection"
data-wp-interactive="woocommerce/product-collection"
data-wp-router-region="<?php echo esc_attr( 'wc-product-collection-' . $query_id ); ?>"
data-wp-watch---cart-reference="callbacks.refreshCartReference"
data-product-reference-type="<?php echo esc_attr( self::REFERENCE_TYPE_CART ); ?>"
></div>
<?php
return (string) ob_get_clean();
}