对于woocommerce中某个类别的特定“存档页面”,请使用不同的缩略图大小

I have a great store made in woocommerce but thumbnails in archive pages for 2 of my 9 different categories are cropped too much since my thumbnails are vertical (700x900), this images for this 2 categories must be in horizontal, using 500x300 so the cropping doesn't affect the picture too much, is this possible?

For example I want to keep all categories to default thumbnails (700x900) but I need category ID 23 and 27 to use 500x300 thumbnails.

I found this code, but I cant make it work for woocommerce:

  if (in_category( '23' )) {
    // different size for one category
    set_post_thumbnail_size( 500, 300, true ); 
} else {
    // default size
    set_post_thumbnail_size( 700, 900, true ); 
}

I already added the custom image size and regenerated my thumbnails.

I will appreciate any help or clues how to solve this.