remove_outofstock_product(); } else { $outOfStockEnabled = $config['is_outOfStock']; } if ( ! $product instanceof \WC_Product ) { return $value; } if ( $outOfStockEnabled && $product->is_type( 'variable' ) && $product->has_child() ) { $attr = "pa_" . $attr; $child_ids = $product->get_children(); $variationAttributes = array_keys( $product->get_variation_attributes() ); if ( ! in_array( $attr, $variationAttributes ) ) { return $value; } $newValue = []; //reset the value to concat by child values foreach ( $child_ids as $id ) { $child_product = wc_get_product( $id ); $attr_value = $child_product->get_attribute( $attr ); if ( ! empty( $attr_value ) && ( $child_product->is_in_stock() || ( $child_product->managing_stock() && 0 < $child_product->get_stock_quantity() ) ) ) { $newValue [] = $attr_value; } } $value = ! empty( $newValue ) ? implode( ', ', $newValue ) : $value; } return $value; } }