• I’m trying to get an online store up and running but I’m having some pains in the latest version of WooCommerce, 2.4.6. I’ve tried using the “storefront” theme as well as “twenty fifteen” and both themes behave the same way with product variants that have not been configured.

    Product page: https://shop.splash-x.com/product/im-just-in-it-for-the-parking/

    The options are there in the drop down to select for variants that don’t exist and when selected they give the message:

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

    A quick overview of how I set things up:

    • I setup attributes for Shirt Color, Shirt Size and Print Color.
    • I created a new product and pulled in those attributes and set them as variations
    • I configured only a select few combinations of Shirt Color and Print color (Royal shirt comes in white print, Black shirt comes in white print or hot pink, Hot Pink comes in black or white print, Navy comes in white and Ash comes in black)
    • I set the default variant to Shirt Color ROYAL, Shirt Size LARGE and Print Color WHITE
    • I set the price for all variants to 15.99
    • I made sure to go in to the WooCommerce settings and set Product => Inventory => “Hide out of stock items from the catalog” to checked.

    Any time you select a shirt color it displays the full list of available print colors, regardless if the print color is available with the shirt color.

    The software is correctly eliminating any Shirt Color and Print Color that is not used, for example there are 15 shirt colors and 14 prints colors and the product page is correctly limiting the output to 5 shirt colors and 3 print colors.

    My problem is I want the select from the Shirt Color box to cause the drop down boxes for Size and Print Color to be adjusted and hide sizes and print colors that are not available with that shirt color.

    I would settle with disabling the sizes and print colors that were not available but I would prefer to straight up hide them, either by hiding or removing options not relevant to the variant.

    I did find this thread on Stack Overflow similar to what I’m asking about:
    https://stackoverflow.com/questions/29879413/greying-out-out-of-stock-product-variations-woocommerce

    I added the filter and the function grey_out_variations_when_out_of_stock and I logged the variation to the PHP log and something interesting happens, when ever you select a variant that does not exist the variation is the LAST selected variation that did exist. For example, the product loads with ROYAL/LARGE/WHITE, change the print color to BLACK and I see in the log that the variant is the ROYAL/LARGE/WHITE. Change it to HOT PINK/LARGE/WHITE and the variant in the log changes. Change it to HOT PINK/LARGE/BLACK and it changes. Change the print color to something not in use, say “Hot Pink” (ex: HOT PINK/LARGE/HOT PINK), again the last good variant is what gets passed to this function.

    I know that the code in the SO post is from May so that puts the latest version at that time at 2.3.x and 2.4.x likely has some breaking changes.

    Maybe someone has some ideas on how to get this working correctly?

    I did not have a catch-all variant, do I need one?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin WooCommerce 2.4.6] Hiding Product Variants Not In Use’ is closed to new replies.