Created
January 21, 2025 03:59
-
-
Save kartikparmar/04d310fd581a00e98d63c909d6247bc0 to your computer and use it in GitHub Desktop.
Sorting attributes in custom order
This file contains hidden or 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
<?php | |
/** | |
* Modify sorting pattern for size attribute. | |
*/ | |
function swpco_weekdays() { | |
/* Following data is assumption that you want the size order in mentioned order. */ | |
return array( | |
's' => 'aaaaaaaaa', | |
'm' => 'aaaaaaaab', | |
'l' => 'aaaaaaaac', | |
'xl' => 'aaaaaaaad', | |
'xxl' => 'aaaaaaaae', | |
'xxxl' => 'aaaaaaaaf', | |
); | |
} | |
add_filter( 'swpco_weekdays', 'swpco_weekdays', 10, 1 ); | |
/** | |
* Modify sorting type for size attribute. | |
*/ | |
function return_type_of_attribute( $type ) { | |
return 'weekday'; | |
} | |
add_filter( 'swpco_attribute_type', 'return_type_of_attribute', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment