Hi Tarek,
I appreciate your quick reply.
I have tried that option, but still the products show with READ MORE.(checked / unchecked option to see custom code might override settings)
Tried,with below code also.
add_filter( ‘woocommerce_products_widget_query_args’, ‘custom_products_widget_query_arg’, 10, 1 );
function custom_products_widget_query_arg( $query_args ) {
??? if( ! is_admin() ) {
??????? $query_args[‘meta_query’][] = array(
??????????? ‘key’???? => ‘_stock_status’,
??????????? ‘value’?? => ‘outofstock’,
??????????? ‘compare’ => ‘!=’
??????? );
??? }
??? return $query_args;
}
add_filter( ‘woocommerce_products_widget_query_args’, ‘custom_products_widget_query_arg’, 10, 1 );
function custom_products_widget_query_arg( $query_args ) {
??? if( ! is_admin() ) {
??????? $query_args[‘tax_query’][] = array(
??????????? ‘taxonomy’ => ‘product_visibility’,
??????????? ‘field’??? => ‘name’,
??????????? ‘terms’??? => array(‘outofstock’),
??????????? ‘operator’ => ‘NOT IN’
??????? );
??? }
??? return $query_args;
}
————add_filter( ‘woocommerce_product_query_meta_query’, ‘shop_only_instock_products’, 10, 2 );
function shop_only_instock_products( $meta_query, $query ) {
// Only on shop archive pages
if( is_admin() || is_search() || ! is_shop() ) return $meta_query;
$meta_query[] = array(
‘key’ => ‘_stock_status’,
‘value’ => ‘outofstock’,
‘compare’ => ‘!=’
);
return $meta_query;
}
add_filter( ‘woocommerce_product_query_meta_query’, ‘filter_product_query_meta_query’, 10, 2 );
function filter_product_query_meta_query( $meta_query, $query ) {
// On woocommerce home page only
if( is_front_page() ){
// Exclude products “out of stock”
$meta_query[] = array(
‘key’ => ‘_stock_status’,
‘value’ => ‘outofstock’,
‘compare’ => ‘!=’,
);
}
return $meta_query;
}———-
PS. product are added as menu tfwooproductgrid
class=”elementor-element elementor-element-8302056 elementor-widget elementor-widget-tfwooproductgrid”