Created
July 19, 2019 12:32
-
-
Save SashkoWooTeam/9275dedc84a64e945dd756fdb09e2257 to your computer and use it in GitHub Desktop.
Exclude Out Of Stock Products
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
| add_filter( 'jet-woo-builder/shortcodes/jet-woo-products/query-args', 'oceanwp_jet_woo_products_query_args' ); | |
| if ( ! function_exists( 'oceanwp_jet_woo_products_query_args' ) ) { | |
| function oceanwp_jet_woo_products_query_args( $args ) { | |
| if ( $outofstock_term = get_term_by( 'name', 'outofstock', 'product_visibility' ) ) { | |
| $args['tax_query'][] = array( | |
| 'taxonomy' => 'product_visibility', | |
| 'field' => 'term_taxonomy_id', | |
| 'terms' => array( $outofstock_term->term_taxonomy_id ), | |
| 'operator' => 'NOT IN' | |
| ); | |
| } | |
| return $args; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment