woothemes/woocommerce — pull request #6182 by franticpsyx (2014-09-07 14:15:23+00:00)
Title: Variations UI improvements for out-of-stock variations + "greying out" ability for variation attributes.

1) Handling of out-of-stock variations.

As @jameskoster pointed out in #5661 if the 'Hide out of stock products' option is enabled and a variation is out of stock, the variation should be hidden. This works correctly already.

However, if the 'Hide out of stock products' option is not enabled, out-of-stock variations should be selectable, in order to view variation information such as price. Currently, this doesn't work correctly, because ```variation_is_visible()``` returns false when a variation is out-of-stock. This results in a i18n_unavailable_text message without any further info shown.

This fix allows out-of-stock variations to be selected and displayed with a regular 'out-of-stock' availability status.

2) Handling of "non-visible" variations.

After fixing (1) the i18n_unavailable_text message is shown *only* when a variation is disabled, or when it has an empty price.

It should be possible to modify this default behaviour and hide disabled variations and variations with an empty price completely. Here, a filter is proposed (```woocommerce_hide_invisible_variations```) which can be used to prevent such variations from being added to the ```available_variations``` array, in the same way that out-of-stock variations are left out when 'Hide out of stock products' is enabled.

3) Ability to grey-out attributes for certain variations.

In some cases it might be desirable to optionally "grey-out" certain variation attributes. Some people may want to use this in order to "grey-out" out-of-stock variations. This can have more applications - such as filtering-out variations based on compatibility (Composite Products).

Here, ```variation_is_active``` is introduced to control the "greying-out" behaviour of the variations script. The method output can be filtered to grey-out "out-of-stock" variations etc.

4) Future work.

Refactor the variations script and possibly include the ability to add context-sensitive information into variation attribute options, such as stock information, pricing info, etc.