Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit b62b0fe

Browse files
authored
REST API: Add the product description to our products endpoint (#309)
* REST API: Add the product description to our products endpoint * Add short_description to the API
1 parent dac6d9b commit b62b0fe

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

includes/class-wgpb-products-controller.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,14 @@ protected function get_product_data( $product, $context = 'view' ) {
291291
$raw_data = parent::get_product_data( $product, $context );
292292
$data = array();
293293

294-
$data['id'] = $raw_data['id'];
295-
$data['name'] = $raw_data['name'];
296-
$data['sku'] = $raw_data['sku'];
297-
$data['price'] = $raw_data['price'];
298-
$data['price_html'] = $raw_data['price_html'];
299-
$data['images'] = $raw_data['images'];
294+
$data['id'] = $raw_data['id'];
295+
$data['name'] = $raw_data['name'];
296+
$data['sku'] = $raw_data['sku'];
297+
$data['description'] = $raw_data['description'];
298+
$data['short_description'] = $raw_data['short_description'];
299+
$data['price'] = $raw_data['price'];
300+
$data['price_html'] = $raw_data['price_html'];
301+
$data['images'] = $raw_data['images'];
300302

301303
return $data;
302304
}
@@ -360,12 +362,14 @@ public function get_item_schema() {
360362
'properties' => array(),
361363
);
362364

363-
$schema['properties']['id'] = $raw_schema['properties']['id'];
364-
$schema['properties']['name'] = $raw_schema['properties']['name'];
365-
$schema['properties']['sku'] = $raw_schema['properties']['sku'];
366-
$schema['properties']['price'] = $raw_schema['properties']['price'];
367-
$schema['properties']['price_html'] = $raw_schema['properties']['price_html'];
368-
$schema['properties']['images'] = array(
365+
$schema['properties']['id'] = $raw_schema['properties']['id'];
366+
$schema['properties']['name'] = $raw_schema['properties']['name'];
367+
$schema['properties']['sku'] = $raw_schema['properties']['sku'];
368+
$schema['properties']['description'] = $raw_schema['properties']['description'];
369+
$schema['properties']['short_description'] = $raw_schema['properties']['short_description'];
370+
$schema['properties']['price'] = $raw_schema['properties']['price'];
371+
$schema['properties']['price_html'] = $raw_schema['properties']['price_html'];
372+
$schema['properties']['images'] = array(
369373
'description' => $raw_schema['properties']['images']['description'],
370374
'type' => 'object',
371375
'context' => array( 'view', 'edit' ),

0 commit comments

Comments
 (0)