diff --git a/plugins/woocommerce/changelog/fix-35639_attribute_term_sort_order b/plugins/woocommerce/changelog/fix-35639_attribute_term_sort_order new file mode 100644 index 00000000000..1ba8b7e0ff0 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-35639_attribute_term_sort_order @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix issue where attribute term dropdown was not adhering to sort order setting. diff --git a/plugins/woocommerce/client/legacy/js/admin/wc-enhanced-select.js b/plugins/woocommerce/client/legacy/js/admin/wc-enhanced-select.js index b77da8e08b1..4d35445642e 100644 --- a/plugins/woocommerce/client/legacy/js/admin/wc-enhanced-select.js +++ b/plugins/woocommerce/client/legacy/js/admin/wc-enhanced-select.js @@ -324,6 +324,7 @@ jQuery( function( $ ) { return { taxonomy: $( this ).data( 'taxonomy' ), limit: $( this ).data( 'limit' ), + orderby: $( this ).data( 'orderby'), term: params.term, action: 'woocommerce_json_search_taxonomy_terms', security: wc_enhanced_select_params.search_taxonomy_terms_nonce diff --git a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php index bd836803ae4..f63e6444159 100644 --- a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php +++ b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php @@ -37,13 +37,17 @@ if ( ! defined( 'ABSPATH' ) ) { } if ( 'select' === $attribute_taxonomy->attribute_type ) { + $attribute_orderby = ! empty( $attribute_taxonomy->attribute_orderby ) ? $attribute_taxonomy->attribute_orderby : 'name'; ?> - ! empty( $attribute_taxonomy->attribute_orderby ) ? $attribute_taxonomy->attribute_orderby : 'name', - 'hide_empty' => 0, - ); $selected_terms = $attribute->get_terms(); if ( $selected_terms ) { foreach ( $selected_terms as $selected_term ) { diff --git a/plugins/woocommerce/includes/class-wc-ajax.php b/plugins/woocommerce/includes/class-wc-ajax.php index 9e7b0b5d1d8..375b1d5a674 100644 --- a/plugins/woocommerce/includes/class-wc-ajax.php +++ b/plugins/woocommerce/includes/class-wc-ajax.php @@ -1745,10 +1745,11 @@ class WC_AJAX { $search_text = isset( $_GET['term'] ) ? wc_clean( wp_unslash( $_GET['term'] ) ) : ''; $limit = isset( $_GET['limit'] ) ? absint( wp_unslash( $_GET['limit'] ) ) : null; $taxonomy = isset( $_GET['taxonomy'] ) ? wc_clean( wp_unslash( $_GET['taxonomy'] ) ) : ''; + $orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : 'name'; $args = array( 'taxonomy' => $taxonomy, - 'orderby' => 'id', + 'orderby' => $orderby, 'order' => 'ASC', 'hide_empty' => false, 'fields' => 'all',