Okay
  Public Ticket #2043248
Filter problem
Open

Comments

  • Jim started the conversation

    I have a problem with the filters. When I filter for products with size 41, many products appear that have size 41 but it's out of stock. Why is that happening?

  •  572
    Linh replied

    Hello

    I have tried to use filter in your shop page but there are does not have size 41 so i changed to size 44 to check and see the result still look good without any out of stock product.

    https://avenue108.gr/shop/?filter_megethos2=1-10cm-44

    Thanks

  • Jim replied

    Check here. In this search I should get only shoes of this category with 41 size. https://avenue108.gr/product-category/gynaikeia/%CE%B5%CF%83%CF%80%CE%B1%CE%BD%CF%84%CF%81%CE%AF%CE%B3%CE%B9%CE%B5%CF%82/?filter_megethos2=41

    The second show that appears (Εσπαντρίγιες flatform FYSD801-SNAKE) is not available on 41 size but it appears.

  •  572
    Linh replied

    Hello

    The filter function is working by the list product size in this list: http://prntscr.com/o0u19l

    Please check again.

    Thanks

  • Jim replied

    So every time the stock change on a size I must remove or add the attribute? This is very time consuming. This is not a very logical functionality of the filter.

  •  572
    Linh replied

    Hello

    That is default woocommerce plugin function. Our team will check to find a solution for this case now.

    Thank for your understanding. 

  • Jim replied

    Hello, I have added this code to my functions.php in the child theme.

    add_action( 'woocommerce_before_shop_loop_item_title', 'wk_out_of_stock_variations_loop' );
    function wk_out_of_stock_variations_loop(){
        global $product;
        if ( $product->product_type == 'variable' ) { // if variation product is out of stock
            $available = $product->get_available_variations();
            if ( $available )foreach ( $available as $instockvar ) {
                if ( isset($instockvar['attributes']['attribute_pa_megethos2'] ) ) {
                  
      
    if(isset($_GET['filter_megethos2'])){
       
       $destostock = $_GET['filter_megethos2'];
      
      
      $array = explode(',', $destostock);
      

        if (in_array($instockvar['attributes']['attribute_pa_megethos2'], $array )&& (!$instockvar['max_qty']>0)){
       global $product;
       $id = $product->get_id();
      
    echo "<style>.post-$id{display: none}</style>";

    }
      else{

      if (in_array($instockvar['attributes']['attribute_pa_megethos2'], $array )&& ($instockvar['max_qty']>0)){
       global $product;
       $id = $product->get_id();
      
    echo "<style>.post-$id{display: block !important}</style>";
      
      }
      }
                
            }
        }
     
    }
    }
    }

    This code is created by a guy to solve this problem, but it's not working on my site but it should. Maybe this can help you find a solution to the problem.

  •  572
    Linh replied

    Thank for your information.

    I will notice our developer to check this filter issue for you.

    Please provide an admin account and FTP account so he can access to check the code and settings.

    Thanks

  •   Jim replied privately
  •  572
    Linh replied

    Thank for your info. He will access and help you check it now.

    Thanks

  •  572
    Linh replied

    Hello

    Thank for your waiting. 

    Our team are checking on the code and it is conflict with other theme function so it can not use with theme.

    Thanks

  • Jim replied

    Is there a work around? This is a big problem in the functionality

  •  572
    Linh replied

    You can check this filter that default of woocommerce: 

    https://themes.woocommerce.com/storefront/shop/page/11/?min_price=2&max_price=1494

    The our of stock product is still display in the result.


    Thanks

  • Jim replied

    Yes I know, this is a woocommerce bug. If you can help me resolve this maybe keep the solution for your theme's better functionality too.

  •  572
    Linh replied

    Hello

    We can not control the woocommerce filter function but we will try to find the solution for this.

    Please contact if you have any other question so i can help.

    Thanks