Created
January 23, 2013 10:23
-
-
Save kloon/4604097 to your computer and use it in GitHub Desktop.
WooCommerce Custom Orderby
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 | |
| add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' ); | |
| function custom_woocommerce_get_catalog_ordering_args( $args ) { | |
| if( isset ( $_SESSION['orderby'] ) ) { | |
| switch ( $_SESSION['orderby'] ) { | |
| case 'sku_asc' : | |
| $args['orderby'] = 'meta_value'; | |
| $args['order'] = 'asc'; | |
| $args['meta_key'] = '_sku'; | |
| break; | |
| } | |
| } | |
| return $args; | |
| } | |
| add_filter('woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby'); | |
| function custom_woocommerce_catalog_orderby( $sortby ) { | |
| $sortby['sku_asc'] = 'SKU'; | |
| return $sortby; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
alias: it goes in your themes functions.php. Google "theme functions.php" and you'll see walkthroughs of how to paste code.