Created
July 19, 2021 11:48
-
-
Save artikus11/61f30fff8b1d4f01ecc4dde082956827 to your computer and use it in GitHub Desktop.
Сортировка товаров на каталоге по остаткам
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
/** | |
* Сортировка товаров на каталоге по остаткам | |
* | |
* @param array $args Массив аргументов для WC_Query | |
* | |
* @return array | |
* | |
* @testedwith WooCommerce 5.5 | |
* @verphp 7.0 | |
* @author Artem Abramovich | |
*/ | |
function art_first_sort_by_stock_amount( $args ): array { | |
$args['orderby'] = 'meta_value'; | |
$args['order'] = 'ASC'; | |
$args['meta_key'] = '_stock_status'; | |
return $args; | |
} | |
add_filter( 'woocommerce_get_catalog_ordering_args', 'art_first_sort_by_stock_amount', 9999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment