Skip to content

Commit 01bb6cd

Browse files
committed
fix: always sort terms manually
1 parent 0330027 commit 01bb6cd

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

plugins/woocommerce/src/Blocks/BlockTypes/ProductFilterTaxonomy.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -309,28 +309,9 @@ private function get_taxonomies() {
309309
* @return array|\WP_Error Hierarchically ordered terms or error.
310310
*/
311311
private function get_hierarchical_terms( string $taxonomy, array $taxonomy_counts, bool $hide_empty, string $orderby, string $order ) {
312-
// For non-hierarchical taxonomies, use standard ordering.
313-
if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
314-
$args = array(
315-
'taxonomy' => $taxonomy,
316-
'orderby' => $orderby,
317-
'order' => $order,
318-
);
319-
320-
if ( $hide_empty ) {
321-
$args['include'] = array_keys( $taxonomy_counts );
322-
} else {
323-
$args['hide_empty'] = false;
324-
}
325-
326-
return get_terms( $args );
327-
}
328-
329-
// Get all terms without specific ordering - we'll apply our own sorting.
330312
$args = array(
331313
'taxonomy' => $taxonomy,
332314
'hide_empty' => false,
333-
'fields' => 'all',
334315
);
335316

336317
if ( $hide_empty ) {
@@ -340,7 +321,11 @@ private function get_hierarchical_terms( string $taxonomy, array $taxonomy_count
340321
$terms = get_terms( $args );
341322

342323
if ( is_wp_error( $terms ) || empty( $terms ) ) {
343-
return $terms;
324+
return array();
325+
}
326+
327+
if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
328+
return $this->sort_terms_by_criteria( $terms, $orderby, $order, $taxonomy_counts );
344329
}
345330

346331
// Use TaxonomyHierarchyData for hierarchy operations.

0 commit comments

Comments
 (0)