New order schema

This commit is contained in:
Claudio Sanches 2016-03-23 09:46:34 -03:00
parent 7c84066ad7
commit efe4b76559
1 changed files with 96 additions and 92 deletions

View File

@ -197,35 +197,10 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'number' => array( 'parent_id' => array(
'description' => __( 'Order number.', 'woocommerce' ), 'description' => __( 'Parent order ID.', 'woocommerce' ),
'type' => 'integer', 'type' => 'integer',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'order_key' => array(
'description' => __( 'Order key.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'created_at' => array(
'description' => __( "The date the order was created, in the site's timezone.", 'woocommerce' ),
'type' => 'date-time',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'updated_at' => array(
'description' => __( "The date the order was last modified, in the site's timezone.", 'woocommerce' ),
'type' => 'date-time',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'completed_at' => array(
'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce' ),
'type' => 'date-time',
'context' => array( 'view', 'edit' ),
'readonly' => true,
), ),
'status' => array( 'status' => array(
'description' => __( 'Order status.', 'woocommerce' ), 'description' => __( 'Order status.', 'woocommerce' ),
@ -234,95 +209,91 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'enum' => $order_statuses, 'enum' => $order_statuses,
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
), ),
'order_key' => array(
'description' => __( 'Order key.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'currency' => array( 'currency' => array(
'description' => __( 'Currency in ISO format.', 'woocommerce' ), 'description' => __( 'Currency the order was created with, in ISO format.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'enum' => array_keys( get_woocommerce_currencies() ), 'enum' => array_keys( get_woocommerce_currencies() ),
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
), ),
'total' => array( 'version' => array(
'description' => __( 'Order total.', 'woocommerce' ), 'description' => __( 'Version of WooCommerce when the order was made.', 'woocommerce' ),
'type' => 'float',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'subtotal' => array(
'description' => __( 'Order subtotal.', 'woocommerce' ),
'type' => 'float',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'total_line_items_quantity' => array(
'description' => __( 'Total of order items.', 'woocommerce' ),
'type' => 'integer', 'type' => 'integer',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'total_tax' => array( 'prices_include_tax' => array(
'description' => __( 'Order tax total.', 'woocommerce' ), 'description' => __( 'Shows if the prices included tax during checkout.', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'date_created' => array(
'description' => __( "The date the order was created, in the site's timezone.", 'woocommerce' ),
'type' => 'date-time',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'date_modified' => array(
'description' => __( "The date the order was last modified, in the site's timezone.", 'woocommerce' ),
'type' => 'date-time',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'customer_id' => array(
'description' => __( 'User ID who owns the order. 0 for guests.', 'woocommerce' ),
'type' => 'integer',
'default' => 0,
'context' => array( 'view', 'edit' ),
),
'discount_total' => array(
'description' => __( 'Total discount amount for the order.', 'woocommerce' ),
'type' => 'float', 'type' => 'float',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'total_shipping' => array( 'discount_tax' => array(
'description' => __( 'Order shipping total.', 'woocommerce' ), 'description' => __( 'Total discount tax amount for the order.', 'woocommerce' ),
'type' => 'float', 'type' => 'float',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'cart_tax' => array( 'shipping_total' => array(
'description' => __( 'Order cart tax.', 'woocommerce' ), 'description' => __( 'Total shipping amount for the order.', 'woocommerce' ),
'type' => 'float', 'type' => 'float',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'shipping_tax' => array( 'shipping_tax' => array(
'description' => __( 'Order shipping tax.', 'woocommerce' ), 'description' => __( 'Total shipping tax amount for the order.', 'woocommerce' ),
'type' => 'float', 'type' => 'float',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'total_discount' => array( 'cart_tax' => array(
'description' => __( 'Order total discount.', 'woocommerce' ), 'description' => __( 'Sum of line item taxes only.', 'woocommerce' ),
'type' => 'float', 'type' => 'float',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'shipping_methods' => array( 'total' => array(
'description' => __( 'Text list of the shipping methods used in the order.', 'woocommerce' ), 'description' => __( 'Grand total.', 'woocommerce' ),
'type' => 'string', 'type' => 'float',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'payment_details' => array( 'total_tax' => array(
'description' => __( 'Payment details.', 'woocommerce' ), 'description' => __( 'Sum of all taxes.', 'woocommerce' ),
'type' => 'object', 'type' => 'float',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
'properties' => array(
'method_id' => array(
'description' => __( 'Payment method ID.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'method_title' => array(
'description' => __( 'Payment method title.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'paid' => array(
'description' => __( 'Shows/define if the order is paid using this payment method.', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'transaction_id' => array(
'description' => __( 'Transaction ID, an optional field to set the transacion ID when complate one payment.', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
),
), ),
'billing_address' => array( 'billing' => array(
'description' => __( 'Billing address.', 'woocommerce' ), 'description' => __( 'Billing address.', 'woocommerce' ),
'type' => 'object', 'type' => 'object',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
@ -368,7 +339,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
), ),
'country' => array( 'country' => array(
'description' => __( 'ISO code of the country.', 'woocommerce' ), 'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
), ),
@ -385,7 +356,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
), ),
), ),
), ),
'shipping_address' => array( 'shipping' => array(
'description' => __( 'Shipping address.', 'woocommerce' ), 'description' => __( 'Shipping address.', 'woocommerce' ),
'type' => 'object', 'type' => 'object',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
@ -431,34 +402,67 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
), ),
'country' => array( 'country' => array(
'description' => __( 'ISO code of the country.', 'woocommerce' ), 'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
), ),
), ),
), ),
'note' => array( 'payment_method' => array(
'description' => __( 'Customer order notes.', 'woocommerce' ), 'description' => __( 'Payment method ID.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
), ),
'customer_ip' => array( 'payment_method_title' => array(
'description' => __( 'Customer IP address.', 'woocommerce' ), 'description' => __( 'Payment method title.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'transaction_id' => array(
'description' => __( 'Unique transaction ID.', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'customer_ip_address' => array(
'description' => __( "Customer's IP address.", 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'customer_user_agent' => array( 'customer_user_agent' => array(
'description' => __( 'Customer User-Agent.', 'woocommerce' ), 'description' => __( 'User agent of the customer.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true, 'readonly' => true,
), ),
'customer_id' => array( 'created_via' => array(
'description' => __( 'Customer ID (user ID).', 'woocommerce' ), 'description' => __( 'Shows where the order was created.', 'woocommerce' ),
'type' => 'integer', 'type' => 'string',
'default' => 0,
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'customer_note' => array(
'description' => __( 'Note left by customer during checkout.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'date_completed' => array(
'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce' ),
'type' => 'date-time',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'date_paid' => array(
'description' => __( "The date the order has been paid, in the site's timezone.", 'woocommerce' ),
'type' => 'date-time',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'cart_hash' => array(
'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ),
'type' => 'float',
'context' => array( 'view', 'edit' ),
'readonly' => true,
), ),
'line_items' => array( 'line_items' => array(
'description' => __( 'Last order data.', 'woocommerce' ), 'description' => __( 'Last order data.', 'woocommerce' ),