Friday 29 June 2018

Woocommerce: Only show some variations on a product page

I have a Woocommerce website with many variable products. These products have numerous colour and size options.

I'd like to limit which variations are displayed, based on which category the product is accessed through.

I thought about creating multiple variable products, but this would have implications for stock. I need a single variable product but multiple "views" of the product that limit which variations are shown.

Detecting the parent category is no problem. I can't work out how limit the number of variations that are displayed. I could prevent the purchase of certain variations using the Woocommerce filter woocommerce_available_variation, but I actually want to remove the options from the page all together.

I see references documentation to "invisible" and "disabled" variations, but I can't see how I might be able to harness these.

I found two filters woocommerce_variation_is_active and woocommerce_variation_is_visible which allow you to grey-out or hide certain information for a particular variation. This still doesn't allow me to prevent them from displaying all together.



from Woocommerce: Only show some variations on a product page

No comments:

Post a Comment