Merge branch 'master' of https://github.com/woothemes/woocommerce
This commit is contained in:
commit
2cbe61b3a9
|
@ -29,6 +29,38 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
protected $rest_base = '';
|
||||
|
||||
/**
|
||||
* Add the schema from additional fields to an schema array.
|
||||
*
|
||||
* The type of object is inferred from the passed schema.
|
||||
*
|
||||
* @param array $schema Schema array.
|
||||
*/
|
||||
protected function add_additional_fields_schema( $schema ) {
|
||||
if ( empty( $schema['title'] ) ) {
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can't use $this->get_object_type otherwise we cause an inf loop.
|
||||
*/
|
||||
$object_type = $schema['title'];
|
||||
|
||||
$additional_fields = $this->get_additional_fields( $object_type );
|
||||
|
||||
foreach ( $additional_fields as $field_name => $field_options ) {
|
||||
if ( ! $field_options['schema'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$schema['properties'][ $field_name ] = $field_options['schema'];
|
||||
}
|
||||
|
||||
$schema['properties'] = apply_filters( 'woocommerce_rest_' . $object_type . '_schema', $schema['properties'] );
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get normalized rest base.
|
||||
*
|
||||
|
|
|
@ -1946,7 +1946,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'backordered' => array(
|
||||
'description' => __( 'Shows if a product is on backorder.', 'woocommerce' ),
|
||||
'description' => __( 'Shows if the product is on backordered.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
@ -2368,7 +2368,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
|
|||
'readonly' => true,
|
||||
),
|
||||
'backordered' => array(
|
||||
'description' => __( 'Shows if a variation is on backorder.', 'woocommerce' ),
|
||||
'description' => __( 'Shows if the variation is on backordered.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
|
|
|
@ -80,7 +80,7 @@ class WC_REST_Report_Top_Sellers_Controller extends WC_REST_Report_Sales_Control
|
|||
|
||||
if ( $product ) {
|
||||
$top_sellers[] = array(
|
||||
'title' => $product->get_title(),
|
||||
'name' => $product->get_title(),
|
||||
'product_id' => (int) $item->product_id,
|
||||
'quantity' => wc_stock_amount( $item->order_item_qty ),
|
||||
);
|
||||
|
@ -105,7 +105,7 @@ class WC_REST_Report_Top_Sellers_Controller extends WC_REST_Report_Sales_Control
|
|||
*/
|
||||
public function prepare_item_for_response( $top_seller, $request ) {
|
||||
$data = array(
|
||||
'title' => $top_seller->title,
|
||||
'name' => $top_seller->name,
|
||||
'product_id' => $top_seller->product_id,
|
||||
'quantity' => $top_seller->quantity,
|
||||
);
|
||||
|
@ -148,8 +148,8 @@ class WC_REST_Report_Top_Sellers_Controller extends WC_REST_Report_Sales_Control
|
|||
'title' => 'top_sellers_report',
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'title' => array(
|
||||
'description' => __( 'Product title.', 'woocommerce' ),
|
||||
'name' => array(
|
||||
'description' => __( 'Product name.', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
|
|
Loading…
Reference in New Issue