diff --git a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/block.js b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/block.js
index c997feedeab..2ae99be2fc4 100644
--- a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/block.js
+++ b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/block.js
@@ -23,7 +23,7 @@ function getCategories( { hasEmpty, isDropdown, isHierarchical } ) {
/**
* Component displaying the categories as dropdown or list.
*/
-const ProductCategoriesBlock = ( { attributes } ) => {
+const ProductCategoriesBlock = ( { attributes, isPreview = false } ) => {
const { hasCount, isDropdown } = attributes;
const categories = getCategories( attributes );
const parentKey = 'parent-' + categories[ 0 ].term_id;
@@ -33,10 +33,10 @@ const ProductCategoriesBlock = ( { attributes } ) => {
{ items.map( ( cat ) => {
const count = hasCount ? ({ cat.count }) : null;
return [
-
{ cat.name } { count }, // eslint-disable-line
- !! cat.children &&
- !! cat.children.length &&
- renderList( cat.children ),
+
+ { cat.name } { count } { /* eslint-disable-line */ }
+ ,
+ !! cat.children && !! cat.children.length && renderList( cat.children ),
];
} ) }
@@ -65,6 +65,10 @@ ProductCategoriesBlock.propTypes = {
* The attributes for this block
*/
attributes: PropTypes.object.isRequired,
+ /**
+ * Whether this is the block preview or frontend display.
+ */
+ isPreview: PropTypes.bool,
};
export default ProductCategoriesBlock;
diff --git a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/edit.js b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/edit.js
index cb3519a4878..49460820e80 100644
--- a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/edit.js
+++ b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/edit.js
@@ -66,7 +66,7 @@ export default function( { attributes, setAttributes } ) {
/>
-
+
);
}
diff --git a/plugins/woocommerce-blocks/assets/php/class-wgpb-block-library.php b/plugins/woocommerce-blocks/assets/php/class-wgpb-block-library.php
index 8da0de736cb..6eb5f7afb17 100644
--- a/plugins/woocommerce-blocks/assets/php/class-wgpb-block-library.php
+++ b/plugins/woocommerce-blocks/assets/php/class-wgpb-block-library.php
@@ -197,6 +197,10 @@ class WGPB_Block_Library {
'pad_counts' => true,
)
);
+ foreach ( $product_categories as &$category ) {
+ $category->link = get_term_link( $category->term_id, 'product_cat' );
+ }
+
// Global settings used in each block.
$block_settings = array(
'min_columns' => wc_get_theme_support( 'product_blocks::min_columns', 1 ),