Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add a default attribute to the pattern if exists #9812

Merged
merged 4 commits into from
Jun 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions patterns/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@
<h3><?php esc_html_e( 'Filter by attribute', 'woo-gutenberg-products-block' ); ?></h3>
<!-- /wp:heading -->

<!-- wp:woocommerce/attribute-filter {"heading":"","lock":{"remove":true}} -->
<div class="wp-block-woocommerce-attribute-filter is-loading" data-attribute-id="0" data-show-counts="true" data-query-type="or" data-heading="" data-heading-level="3"><span aria-hidden="true" class="wc-block-product-attribute-filter__placeholder"></span></div>
<?php
$attribute_id = 0;

$attributes = wc_get_attribute_taxonomies();
if ( ! empty( $attributes ) ) {
$attribute_id = reset( $attributes )->attribute_id;
}
?>

<!-- wp:woocommerce/attribute-filter {"attributeId":<?php echo esc_html( $attribute_id ); ?>,"heading":"","lock":{"remove":true}} -->
<div class="wp-block-woocommerce-attribute-filter is-loading" data-attribute-id="<?php echo esc_html( $attribute_id ); ?>" data-show-counts="true" data-query-type="or" data-heading="" data-heading-level="3"><span aria-hidden="true" class="wc-block-product-attribute-filter__placeholder"></span></div>
<!-- /wp:woocommerce/attribute-filter --></div>
<!-- /wp:woocommerce/filter-wrapper -->

Expand Down