Add date_created_gmt property to orders endpoint (https://github.com/woocommerce/woocommerce-admin/pull/2086)
* Add date_created_gmt property to orders enpoint * Make date_created properties of type date-time and improve descriptions
This commit is contained in:
parent
95d1a1d245
commit
8bc2261c8a
|
@ -170,8 +170,14 @@ class WC_Admin_REST_Reports_Orders_Controller extends WC_Admin_REST_Reports_Cont
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
),
|
),
|
||||||
'date_created' => array(
|
'date_created' => array(
|
||||||
'description' => __( 'Date the order was created.', 'woocommerce-admin' ),
|
'description' => __( "Date the order was created, in the site's timezone.", 'woocommerce-admin' ),
|
||||||
'type' => 'string',
|
'type' => 'date-time',
|
||||||
|
'context' => array( 'view', 'edit' ),
|
||||||
|
'readonly' => true,
|
||||||
|
),
|
||||||
|
'date_created_gmt' => array(
|
||||||
|
'description' => __( 'Date the order was created, as GMT.', 'woocommerce-admin' ),
|
||||||
|
'type' => 'date-time',
|
||||||
'context' => array( 'view', 'edit' ),
|
'context' => array( 'view', 'edit' ),
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
),
|
),
|
||||||
|
|
|
@ -94,6 +94,7 @@ class WC_Admin_Install {
|
||||||
order_id bigint(20) unsigned NOT NULL,
|
order_id bigint(20) unsigned NOT NULL,
|
||||||
parent_id bigint(20) unsigned DEFAULT 0 NOT NULL,
|
parent_id bigint(20) unsigned DEFAULT 0 NOT NULL,
|
||||||
date_created datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
date_created datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||||
|
date_created_gmt datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||||
num_items_sold int(11) DEFAULT 0 NOT NULL,
|
num_items_sold int(11) DEFAULT 0 NOT NULL,
|
||||||
gross_total double DEFAULT 0 NOT NULL,
|
gross_total double DEFAULT 0 NOT NULL,
|
||||||
tax_total double DEFAULT 0 NOT NULL,
|
tax_total double DEFAULT 0 NOT NULL,
|
||||||
|
|
|
@ -28,6 +28,7 @@ class WC_Admin_Reports_Orders_Data_Store extends WC_Admin_Reports_Data_Store imp
|
||||||
'order_id' => 'intval',
|
'order_id' => 'intval',
|
||||||
'parent_id' => 'intval',
|
'parent_id' => 'intval',
|
||||||
'date_created' => 'strval',
|
'date_created' => 'strval',
|
||||||
|
'date_created_gmt' => 'strval',
|
||||||
'status' => 'strval',
|
'status' => 'strval',
|
||||||
'customer_id' => 'intval',
|
'customer_id' => 'intval',
|
||||||
'net_total' => 'floatval',
|
'net_total' => 'floatval',
|
||||||
|
@ -54,6 +55,7 @@ class WC_Admin_Reports_Orders_Data_Store extends WC_Admin_Reports_Data_Store imp
|
||||||
'order_id' => "{$table_name}.order_id",
|
'order_id' => "{$table_name}.order_id",
|
||||||
'parent_id' => "{$table_name}.parent_id",
|
'parent_id' => "{$table_name}.parent_id",
|
||||||
'date_created' => "{$table_name}.date_created",
|
'date_created' => "{$table_name}.date_created",
|
||||||
|
'date_created_gmt' => "{$table_name}.date_created_gmt",
|
||||||
'status' => "REPLACE({$table_name}.status, 'wc-', '') as status",
|
'status' => "REPLACE({$table_name}.status, 'wc-', '') as status",
|
||||||
'customer_id' => "{$table_name}.customer_id",
|
'customer_id' => "{$table_name}.customer_id",
|
||||||
'net_total' => "{$table_name}.net_total",
|
'net_total' => "{$table_name}.net_total",
|
||||||
|
|
|
@ -410,6 +410,7 @@ class WC_Admin_Reports_Orders_Stats_Data_Store extends WC_Admin_Reports_Data_Sto
|
||||||
'order_id' => $order->get_id(),
|
'order_id' => $order->get_id(),
|
||||||
'parent_id' => $order->get_parent_id(),
|
'parent_id' => $order->get_parent_id(),
|
||||||
'date_created' => $order->get_date_created()->date( 'Y-m-d H:i:s' ),
|
'date_created' => $order->get_date_created()->date( 'Y-m-d H:i:s' ),
|
||||||
|
'date_created_gmt' => gmdate( 'Y-m-d H:i:s', $order->get_date_created()->getTimestamp() ),
|
||||||
'num_items_sold' => self::get_num_items_sold( $order ),
|
'num_items_sold' => self::get_num_items_sold( $order ),
|
||||||
'gross_total' => $order->get_total(),
|
'gross_total' => $order->get_total(),
|
||||||
'tax_total' => $order->get_total_tax(),
|
'tax_total' => $order->get_total_tax(),
|
||||||
|
@ -423,6 +424,7 @@ class WC_Admin_Reports_Orders_Stats_Data_Store extends WC_Admin_Reports_Data_Sto
|
||||||
'%d',
|
'%d',
|
||||||
'%d',
|
'%d',
|
||||||
'%s',
|
'%s',
|
||||||
|
'%s',
|
||||||
'%d',
|
'%d',
|
||||||
'%f',
|
'%f',
|
||||||
'%f',
|
'%f',
|
||||||
|
|
|
@ -114,7 +114,8 @@ class WC_Tests_API_Reports_Orders extends WC_REST_Unit_Test_Case {
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
$properties = $data['schema']['properties'];
|
$properties = $data['schema']['properties'];
|
||||||
|
|
||||||
$this->assertEquals( 9, count( $properties ) );
|
$this->assertEquals( 10, count( $properties ) );
|
||||||
|
$this->assertArrayHasKey( 'date_created_gmt', $properties );
|
||||||
$this->assertArrayHasKey( 'order_id', $properties );
|
$this->assertArrayHasKey( 'order_id', $properties );
|
||||||
$this->assertArrayHasKey( 'order_number', $properties );
|
$this->assertArrayHasKey( 'order_number', $properties );
|
||||||
$this->assertArrayHasKey( 'date_created', $properties );
|
$this->assertArrayHasKey( 'date_created', $properties );
|
||||||
|
|
Loading…
Reference in New Issue