Created
November 24, 2022 13:05
-
-
Save temsool/74a3275f5bc905866095a4366a49faba to your computer and use it in GitHub Desktop.
ACF Pro relationship only show in stock products woocommerce
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 | |
add_filter('acf/fields/relationship/query/name=also_may_like', 'exclude_outofstock', 10, 3); | |
function exclude_outofstock ( $args, $field, $post_id ) { | |
$meta_query[] = [ | |
'key' => '_stock_status', | |
'value' => 'instock', | |
'compare' => '=', | |
]; | |
$args['meta_query']= $meta_query; | |
return $args; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment