26

enter image description here

I have changed dropdown to radio button using wc-variations-radio-buttons-master The different color is also actually radio button.

The current link product have 12 such variation which have product and not other. Some combination I can explain such as Silver,Matching upholstery,VC,RegularSeat and Silver,Matching upholstery,ACC,RegularSeat have product while Silver,Matching upholstery,Regular,RegularSeat have not product now i want to hide Regular option from current scenario and all other such option which have not product.

I meant to show those radio button which have product if not then hide irrelevant radio button

Product link

Sajid anwar
  • 1,194
  • 14
  • 41
  • 1
    All other product have variation but for this special product i can hardcode if any solution found – Sajid anwar Sep 06 '16 at 07:46
  • 1
    I am having a hard time understanding what you are looking for. Can you make your question clearer or provide an example? – Shawn Sep 08 '16 at 21:15
  • I have modified my question please check now @Shawn – Sajid anwar Sep 09 '16 at 06:03
  • 2
    You have to draft your own algorithms to check what desired result you want to show for what options the user has selected. 1. Before user comes to the detail page of the product, you need to implement a check that the selection he made, does there are products in the selection or not. 2. Similar will be other cases Silver,Matching upholstery,VC,RegularSeat etc – gurmandeep Sep 14 '16 at 02:56
  • please add product of all category @Coder – Savan Dholu Dec 22 '16 at 06:28
  • I have updated my link now click on link @SavanDholu – Sajid anwar Dec 22 '16 at 12:28

4 Answers4

8

If I understand your question correctly, you want woocommerce to prevent users from selecting certain combinations of options on variable products, unless a variation with the selected options actually exists and is in stock?

This probably is due to the woocommerce_ajax_variation_threshold. If your product contains more variations than the threshold specifies, woocommerce will wait until all variation options have been selected by the user before determining if the selected combination of options is valid(in stock, exists, etc). If the user has selected a combination that is not valid or is not instock, you will get the

Sorry, no products matched your selection. Please choose a different combination

Say you had a product where you can set the following attributes:

upholstery, base, arms headrest, back

That is 5 different attributes. If each one of those attributes has 5 options, that is 25 different possible combinations assuming the user has to select all 5 options. If the user doesn't have to select all 5 options then there are even more possible combinations.

So even if you only actually created 2 variations for this product, its woocommerce_ajax_variation_threshold would be 25, meaning 25 possible options(variations).

I think by default the woocommerce_ajax_variation_threshold is set to 10.

So to fix(filter) this, set the woocommerce_ajax_variation_threshold to a higher value. If your product has 30 possible combinations(whether they actually exist or not) set the threshold to something higher than 30, like 1111 for example.

You can use the snippet below in your functions.php file.

 /* Increase Woocommerce Variation Threshold */
 function wc_ajax_variation_threshold_modify( $threshold, $product ){
  $threshold = '1111';
  return  $threshold;
 }
add_filter( 'woocommerce_ajax_variation_threshold','wc_ajax_variation_threshold_modify', 10, 2 );
Brev Tiw
  • 573
  • 6
  • 8
  • 1
    This is exactly what I needed, I cannot believe more people haven't run into this situation. – Sam May 13 '20 at 05:30
  • Thank you - ran into this issue with bulk uploading variations through a csv. After lots of messing about in the csv thinking it was how I was importing the data. I didn't think this would be the root cause. – deepfriedmars Jun 15 '23 at 11:40
1

Please check variation matrix table, for correctly matched select of all variants with each other....

Eg.

2x2 means 11 12 21 22

3x3

111 122 113 221 222 223 331 332 333

OpenWebWar
  • 580
  • 8
  • 16
0

One of the quirks in WooCommerce that causes this sort of situation is not having prices on all of your variations, the system does not always tell you that it is required so unexpected things can happen. Please check your variation data and make sure all variations have a price.

Kodaloid
  • 1,211
  • 11
  • 19
0

"By default, if a Variable product has fewer than 30 variations, the dropdowns for selecting variations on the frontend will be dynamic."

https://woocommerce.com/document/change-limit-on-number-of-variations-for-dynamic-variable-product-dropdowns/