• Resolved drahnier

    (@drahnier)


    We use your plugin version: 1.2.1 and have found a programming error.

    Please check your code in the file “class-frontend.php” in line 246.
    The way you write it can’t work!
    You cannot have multiple of the same key in an associative array!

    1.) I changed that to:
    $array[] = $variation['attributes'];

    2.) Then the lines in lines 154 to 184 must also be adjusted as follows:

    foreach ( $terms as $term ) {
    	if ( in_array( $term->slug, $options ) ) {
    		
    			$meta_key = md5( $term->slug );
    			
    			if ( isset( $swatch_type_options[$key] ) && $swatch_type_options[$key]['type'] == 'product_color' ) {
    				$meta_options['value'] =  ( isset (  $swatch_type_options[ $key ][ $meta_key ]['color'] ) && $swatch_type_options[ $key ][ $meta_key ]['color'] != "" ) ? $swatch_type_options[ $key ][ $meta_key ]['color'] :''; 
    				$meta_options['type'] = 'color';
    			}
    			
    			if ( isset( $swatch_type_options[$key] ) && $swatch_type_options[$key]['type'] == 'product_image' ) {
    				$meta_options['value'] =  ( isset (  $swatch_type_options[ $key ][ $meta_key ]['image'] ) && $swatch_type_options[ $key ][ $meta_key ]['image'] != "" ) ? $swatch_type_options[ $key ][ $meta_key ]['image'] :''; 
    				$meta_options['type'] = 'image';
    				
    			}
    			if ( isset( $swatch_type_options[$key] ) && $swatch_type_options[$key]['type'] == 'product_label' ) {
    				$meta_options['value'] =  ''; 
    				$meta_options['type'] = 'label';
    			}
    		//$stock['attribute_'.$attribute]	
    		$meta_options['stock_checker'] = '';
    		
    		/* if( isset( $stock['attribute_'.$attribute] ) && $stock['attribute_'.$attribute] == $term->slug ){
    					$meta_options['stock_checker'] = 'out_of_stock';
    		} */
    		
    		for($x = 0; $x < count($stock);$x++){
    			if(isset($stock[$x]['attribute_'.$attribute]) && in_array($term->slug, $stock[$x])){
    				$meta_options['stock_checker'] = 'out_of_stock';
    				break;
    			}
    		}
    	
    		$swatches .= apply_filters( 'atawc_swatch_html', '', $term, $attr, $args, $meta_options );
    		
    	}
    }
    

    That’s working fine!

    Can you please program this in a next update?

    Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Author aThemeArt

    (@athemeart)

    Hi @drahnier
    Thanks for help! we have added your code with a new version of the Smart Variation Swatches plugins, would you check once.

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘stock_check && get_swatch_html’ is closed to new replies.