Created
November 13, 2019 14:19
-
-
Save simonporter007/952b570b61582abc8b8be97d04b155cc to your computer and use it in GitHub Desktop.
WooCommerce Extra Product Sorting Options: Adjust the query used with 'sale items first' to also show non sale items
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
<?php // only copy if required! | |
// Allows products with no sale price to display alongside sale items | |
function sv_posts_clauses( $args, $wp_query ) { | |
$args = str_replace("wp_postmeta.meta_key = '_sale_price'","wp_postmeta.meta_key IN ('_sale_price', '_virtual')", $args); | |
return $args; | |
} | |
add_filter( 'posts_clauses', 'sv_posts_clauses', 15, 2 ); |
Thanks for letting me know, that's great news! I'm afraid the plugin doesn't support variable product sorting at this time but thanks so much for the feedback!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, it is working fine, only sorting single products, but not variable products.