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?

  •  389
    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.

  •  389
    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.

  •  389
    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.

  •  389
    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
  •  389
    Linh replied

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

    Thanks