Add empty content messages (https://github.com/woocommerce/woocommerce-blocks/pull/717)
* Return empty result if no products are found * Add empty response handler * Update to latest PR * Pass render prop
This commit is contained in:
parent
e227dff18e
commit
5f4949ac6b
|
@ -244,6 +244,21 @@ class ProductByCategoryBlock extends Component {
|
|||
<ServerSideRender
|
||||
block={ name }
|
||||
attributes={ attributes }
|
||||
EmptyResponsePlaceholder={ () => (
|
||||
<Placeholder
|
||||
icon="category"
|
||||
label={ __(
|
||||
'Products by Category',
|
||||
'woo-gutenberg-products-block'
|
||||
) }
|
||||
className="wc-block-products-grid wc-block-products-category"
|
||||
>
|
||||
{ __(
|
||||
'No products were found that matched your selection.',
|
||||
'woo-gutenberg-products-block'
|
||||
) }
|
||||
</Placeholder>
|
||||
) }
|
||||
/>
|
||||
) : (
|
||||
__(
|
||||
|
|
|
@ -68,8 +68,13 @@ abstract class AbstractProductGrid extends AbstractDynamicBlock {
|
|||
$this->content = $content;
|
||||
$this->query_args = $this->parse_query_args();
|
||||
$products = $this->get_products();
|
||||
$classes = $this->get_container_classes();
|
||||
$output = implode( '', array_map( array( $this, 'render_product' ), $products ) );
|
||||
|
||||
if ( ! $products ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$classes = $this->get_container_classes();
|
||||
$output = implode( '', array_map( array( $this, 'render_product' ), $products ) );
|
||||
|
||||
return sprintf( '<div class="%s"><ul class="wc-block-grid__products">%s</ul></div>', esc_attr( $classes ), $output );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue