How to override an image size in WooCommerce

Product single

<?php add_filter( 'woocommerce_get_image_size_single', function( $size ) { return array( 'width' => 400,
		'height' => '',
		'crop'   => 0,
	);
} );

add_filter( 'woocommerce_get_image_size_single', function( $size ) {
	return array(
		'width'  => 500,
		'height' => 500,
		'crop'   => 1,
	);
} );

Thumbnail (for shop and category pages)

add_filter( 'woocommerce_get_image_size_thumbnail', function( $size ) {
	return array(
		'width'  => 500,
		'height' => 500,
		'crop'   => 1,
	);
} );

Gallery

add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {
	return array(
		'width'  => 400,
		'height' => 400,
		'crop'   => 1,
	);
} );