• Resolved naveeed

    (@naveeed)


    How can I Hiding Out of Stock Products Woolentor Product Grid
    or please guide for the code,
    as below code did not work

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Tarek Aziz

    (@tarekht)

    Hello @naveeed

    Thanks for reaching out to us ??

    Unfortunately, the option to hide out of stock products individually is not available in the “Product Grid” widget.

    Alternatively, you can hide all of the out of stock products in your WooCommerce store. To do so, please follow the screenshot below:

    https://tppr.me/Ua5f9

    It will also prevent the out of stock products from getting displayed in the widget.

    NOTE: We’ll definitely consider adding this feature to the widget in a future update.

    Best regards,
    Tarek

    Thread Starter naveeed

    (@naveeed)

    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”

    Plugin Contributor Tarek Aziz

    (@tarekht)

    Hi @naveeed

    Thank you very much for your response.

    With due respect, this sort of issue should not have happened after enabling the option to hide the out of stock products.

    The “READ MORE” only shows for the external/affiliate products. I think the products you are seeing are not exactly out of stock products.

    Moreover, the WooLentor plugin doesn’t have any filter named “woocommerce_products_widget_query_args

    That’s why the code didn’t work as expected.

    It would be great if you could reach out to us via our support website.

    Kind regards,
    Tarek

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hiding Out of Stock Products Woolentor Product Grid’ is closed to new replies.