Ensure Product on Store API always contain an array of images that can be encoded into a JSON array (no named indexes), as per its own schema declaration. (https://github.com/woocommerce/woocommerce-blocks/pull/8499)

This commit is contained in:
Paulo Arromba 2023-02-22 13:12:12 +00:00 committed by GitHub
parent e580c1a6af
commit 78b4e3fcb7
1 changed files with 1 additions and 1 deletions

View File

@ -494,7 +494,7 @@ class ProductSchema extends AbstractSchema {
protected function get_images( \WC_Product $product ) {
$attachment_ids = array_merge( [ $product->get_image_id() ], $product->get_gallery_image_ids() );
return array_filter( array_map( [ $this->image_attachment_schema, 'get_item_response' ], $attachment_ids ) );
return array_values( array_filter( array_map( [ $this->image_attachment_schema, 'get_item_response' ], $attachment_ids ) ) );
}
/**