Home Forums WoodMart support forum Issue in variation out of stock in product archive

Issue in variation out of stock in product archive

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #423202

    dadi
    Participant

    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';
    }
    
    #423379

    Artem Temos
    Keymaster

    Hello,

    Thank you for posting your solution here. We will review this for future updates.

    Kind Regards

Viewing 2 posts - 1 through 2 (of 2 total)