Last active
May 4, 2020 23:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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