Disable (grey Out) Out-of-stock Swatches - Iconic

PHOTO EMBED

Wed Jun 16 2021 06:59:05 GMT+0000 (UTC)

Saved by @deveseospace #php

/**
 * Disable out of stock variations
 *
 * @param bool $active
 * @param WC_Product_Variation $variation
 *
 * @return Boolean
 */
function iconic_variation_is_active( $active, $variation ) {
	if( ! $variation->is_in_stock() ) {
		return false;
	}

	return $active;
}

add_filter( 'woocommerce_variation_is_active', 'iconic_variation_is_active', 10, 2 );
content_copyCOPY

https://iconicwp.com/docs/woocommerce-attribute-swatches/disable-grey-out-out-of-stock-swatches/