[Resolved] Different Woocommerce archive image sizes/columns for specific categories

Home Forums Support [Resolved] Different Woocommerce archive image sizes/columns for specific categories

Home Forums Support Different Woocommerce archive image sizes/columns for specific categories

Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #986779
    Raul

    In terms of the dynamic selection of layout (1 column) via ACF true/false field, here is the code that worked for me in case anyone is interested:

    // Use 1 column layout for Art Series with one work -ACF based 
    function vv_custom_cat_layout( $options ) {
    	$terms = get_terms([
    		'taxonomy' 		=> 'product_cat',
    		'hide_empty' 	=> true,
    		'meta_query' 	=> [
    			'key'		=> 'series_one_work',
    			'value'		=> 1
    		]
    	]);
       	$AcfFilter = [];
    	foreach($terms as $term)
    		array_push($AcfFilter, $term->slug); // i'm never sure if is term_name or just name, sorry
    
    	if ( is_product_category( $AcfFilter ) )
    		$options['columns'] = 1;
    
    	return $options;
    
    }
    
    add_filter( 'option_generate_woocommerce_settings','vv_custom_cat_layout' );
    #986857
    Tom
    Lead Developer
    Lead Developer

    Hmm ok, let’s try this then:

    add_filter( 'option_woocommerce_thumbnail_image_width', function( $width ) {
        $terms = get_terms([
            'taxonomy' 		=> 'product_cat',
            'hide_empty' 	=> true,
            'meta_query' 	=> [
                'key'		=> 'series_one_work',
                'value'		=> 1
            ]
        ]);
    
        $AcfFilter = [];
    
        foreach($terms as $term) {
            array_push($AcfFilter, $term->slug); // i'm never sure if is term_name or just name, sorry
        }
    
        if ( is_product_category( $AcfFilter ) )
            return 1000;
        }
    
        return $width;
    } );
    #1314454
    Raul

    Thank you Tom!

Viewing 3 posts - 16 through 18 (of 18 total)
  • You must be logged in to reply to this topic.