Hello,
I found issue in the theme. Variation is in stock is only checked if there is a image for variation. So if a variation is out of stock I couldn’t get the variation-out-of-stock class and set some style to the variation.
if ( ! empty( $variation['image']['src'] ) && $variation_image ) {
$option_variation = array(
'variation_id' => $variation['variation_id'],
'is_in_stock' => $variation['is_in_stock'],
'image_src' => $variation['image']['src'],
'image_srcset' => $variation['image']['srcset'],
'image_sizes' => $variation['image']['sizes'],
);
}
I added so is_in_stock is always checked and added to the variation and changed this:
if ( isset( $swatch['image_src'] ) ) {
$data .= 'data-image-src="' . $swatch['image_src'] . '"';
$data .= ' data-image-srcset="' . $swatch['image_srcset'] . '"';
$data .= ' data-image-sizes="' . $swatch['image_sizes'] . '"';
if ( ! $swatch['is_in_stock'] ) {
$class .= ' variation-out-of-stock';
}
}
to this
if ( isset( $swatch['image_src'] ) ) {
$data .= 'data-image-src="' . $swatch['image_src'] . '"';
$data .= ' data-image-srcset="' . $swatch['image_srcset'] . '"';
$data .= ' data-image-sizes="' . $swatch['image_sizes'] . '"';
}
if ( ! $swatch['is_in_stock'] ) {
$class .= ' variation-out-of-stock';
}