• Resolved VORAg

    (@yasgch46)


    Hi good day! I have an elementor pro license, but I can’t get a products widget to only show the products in stock.

    Do you have any idea how to hide out of stock products with css just for the widget?

    I tried it with dynamic tags but I can’t.

    Edit: There is no way to only filter by stock, show products with the minimum quantity of stock: 1 piece.

    https://ibb.co/FxNQxVT

    • This topic was modified 3 years, 1 month ago by VORAg.
    • This topic was modified 3 years, 1 month ago by VORAg.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter VORAg

    (@yasgch46)

    I was thinking that by modifying this code I can achieve it, since there is no option to filter by default stock.

    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() ){ // Maybe modifyng this condition
            // Exclude products "out of stock"
            $meta_query[] = array(
                'key'     => '_stock_status',
                'value'   => 'outofstock',
                'compare' => '!=',
            );
        }
        return $meta_query;
    }

    Maybe there is a way to identify the widget and add it as a condition in the above code and add it to my theme’s functions.php file.

    saidaboukhadra

    (@saidaboukhadra)

    Hello,

    We apologize for the delay.
    If the case is still relevant, please submit a ticket by sending an email to “support@elementor.com”

    We will look into it and handle it deeply.

    Regards,
    Said

    Thread Starter VORAg

    (@yasgch46)

    Don’t worry, it only took a month. I also opened a ticket in official support and they have not answered me.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide out of stock products from a widget in elementor & woocommerce’ is closed to new replies.