Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save abdulawal39/51f686c1026556b1f0a1201285db443b to your computer and use it in GitHub Desktop.
Save abdulawal39/51f686c1026556b1f0a1201285db443b to your computer and use it in GitHub Desktop.
Sort WooCommerce Product Attribute Values on single product page. Details on: https://abdulawal.com/?p=1463
/**
* Sort Attribute values in ascending order for any attribute
* @param array $args
* @return array return sorted $args array
*/
function abd_sort_wc_attribute_values( $args ){
$get_options = $args['options'];
asort( $get_options );
$args['options'] = $get_options;
return $args;
}
add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'abd_sort_wc_attribute_values', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment