Title: Filtering variations
Last modified: January 26, 2018

---

# Filtering variations

 *  Resolved [Koesterandersen](https://wordpress.org/support/users/koesterandersen/)
 * (@koesterandersen)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/filtering-variations/)
 * Hi
 * I am having some problems with the filtering function on this site.
 * For two similar products the filtering seems to function on the one and not on
   the other.
 * If I choose this product: “El-motor, byggeform b14” the filter functionality 
   eliminates the unrelevant product variations as I make a choice i fx the first
   variation. This means that I can get through to an existing product at the end
   of my choices – of which there are 5 (for each product)
 * If I choose this product: “El-motor, byggeform b3” the filter functionality do
   not eliminates unrelevant product variations at all, which means that I most 
   times will get to a message that the product do not exist.
 * I have tried to find some differences at the products in the admin where I create
   and edit products, but it seems to me, that there are no differences.
 * I hope someone might have some solution for this problem.
 * From Mikael
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ffiltering-variations%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Erina (a11n)](https://wordpress.org/support/users/eri32s98/)
 * (@eri32s98)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/filtering-variations/#post-9908159)
 * Can you provide more details please?
 * For example, on [https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b3/](https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b3/),
   what are you expecting that is missing? How can we reproduce the issue?
 *  Thread Starter [Koesterandersen](https://wordpress.org/support/users/koesterandersen/)
 * (@koesterandersen)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/filtering-variations/#post-9909111)
 * Hi
 * On that link it is supposed to function in the following way:
    When you choose
   100 in Byggestørrelse (first choice), it should only show 2.2 and 3 in KW (third
   choice). But it is showing much more attributes.
 * I have made a testproduct, which is function the right way – though it has fewer
   variations. I made it only to test.
    It is this one: [https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b3-tester/](https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b3-tester/)
 * If you choose 100 in Byggestørrelse (first choice), it should only show 0.25 
   KW (third choice). And this works fine.
    If you start with no choices in this
   product and see the attributes ind the KW, you will se, that it contains 3 attributes.
 * I hope these examples helps explaining the problem.
 * Additional information. These products works fine:
    [https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b5/](https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b5/)
   [https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b14/](https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b14/)
   [https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-dupli14/](https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-dupli14/)(
   also a test) [https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b34/](https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b34/)
 * The two products that do not work is the these ones:
    [https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b3/](https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b3/)
   [https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b35/](https://www.3skruerog1bolt.dk/shop/elmotorer/el-motor-byggeform-b35/)
 * When some products works and some do not, I am pretty sure that it is not an 
   error in the system, but I cannot figure out what I probably has made wrong.
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/filtering-variations/#post-9909264)
 * See:
    [https://wordpress.org/support/topic/24-handling-for-20-variations?replies=1](https://wordpress.org/support/topic/24-handling-for-20-variations?replies=1)
 * The variations “threshold” is usually 30, though that can vary by theme. If you
   have less variations than the threshold, all the variations are loaded with the
   page, and unavailable variations cannot be selected. If you have more variations
   than the threshold, any combination can be selected, then ajax will be used to
   find out if the selected variation is available, and sometimes its not.
 * You can increase the variations threshold using this snippet in functions.php
   for your child theme:
    [https://gist.github.com/mohsinoffline/f06c66259e667d6b16bb](https://gist.github.com/mohsinoffline/f06c66259e667d6b16bb)
 * As you make the threshold bigger, the page size gets bigger so page load time
   will increase. You’ll need to make a judgement.
 *  Thread Starter [Koesterandersen](https://wordpress.org/support/users/koesterandersen/)
 * (@koesterandersen)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/filtering-variations/#post-9922591)
 * Hi
 * I found the snippet and when I am setting it into the functions.php file I get
   a response telling me that the code snippet has some error.
 * Could you please correct the snippet in order to make it work, og perhaps telling
   me where to put it in the functions.php file.
 * It is this snippet, I have found and tried to use. The error is supposed to be
   in the first line: <?php
 * <?php
    function ww_ajax_variation_threshold( $default, $product ) { return 50;//
   increase this number if needed } add_filter( ‘woocommerce_ajax_variation_threshold’,‘
   ww_ajax_variation_threshold’, 10, 2 ); ?>
 *  Thread Starter [Koesterandersen](https://wordpress.org/support/users/koesterandersen/)
 * (@koesterandersen)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/filtering-variations/#post-9922694)
 * Hi
 * I have find the solution myself. And yes – it was me, who made the error…by putting
   both <?php and ?> into the functions.php file.
 * For people like me, who cannot code, it could be an advantage, if code snippets
   like this one are stripped for everything, that should not be put into the functions.
   php file.
 * When I find code snippets at StudioPress to the Genesis Framework and functions.
   php file, the codes are ready to be put in – and you might do it the same way.
   
   Just a suggestion. (-:
 * Thank you anyway for your support and the code is working just fine and as I 
   wanted it to do.
 * From
    Mikael

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Filtering variations’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [filtering](https://wordpress.org/support/topic-tag/filtering/)
 * [variations](https://wordpress.org/support/topic-tag/variations/)

 * 5 replies
 * 3 participants
 * Last reply from: [Koesterandersen](https://wordpress.org/support/users/koesterandersen/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/filtering-variations/#post-9922694)
 * Status: resolved