From c8527468c557c72edf1aa587cd79789764cbbafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonino=20Scarf=C3=AC?= Date: Mon, 30 May 2016 15:16:26 +0200 Subject: [PATCH 01/11] Use hook to include navigation.php template --- includes/wc-template-functions.php | 10 ++++++++++ includes/wc-template-hooks.php | 1 + templates/myaccount/downloads.php | 9 +++++++-- templates/myaccount/form-add-payment-method.php | 7 ++++++- templates/myaccount/form-edit-account.php | 7 ++++++- templates/myaccount/form-edit-address.php | 7 ++++++- templates/myaccount/my-account.php | 9 +++++++-- templates/myaccount/orders.php | 8 +++++++- templates/myaccount/payment-methods.php | 10 ++++++++-- templates/myaccount/view-order.php | 9 +++++++-- 10 files changed, 65 insertions(+), 12 deletions(-) diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index fbb2435de09..f8541532a8f 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -2091,6 +2091,16 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) { } } +if ( ! function_exists( 'woocommerce_account_navigation' ) ) { + + /** + * My Account navigation template. + */ + function woocommerce_account_navigation() { + wc_get_template( 'myaccount/navigation.php' ); + } +} + if ( ! function_exists( 'woocommerce_account_orders' ) ) { /** diff --git a/includes/wc-template-hooks.php b/includes/wc-template-hooks.php index 96a27981a04..790b7b7b512 100644 --- a/includes/wc-template-hooks.php +++ b/includes/wc-template-hooks.php @@ -256,6 +256,7 @@ add_filter( 'jetpack_comment_form_enabled_for_product', '__return_false' ); /** * My Account. */ +add_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' ); add_action( 'woocommerce_account_orders_endpoint', 'woocommerce_account_orders' ); add_action( 'woocommerce_account_view-order_endpoint', 'woocommerce_account_view_order' ); add_action( 'woocommerce_account_downloads_endpoint', 'woocommerce_account_downloads' ); diff --git a/templates/myaccount/downloads.php b/templates/myaccount/downloads.php index a48f34e450c..84c1dbd2abe 100644 --- a/templates/myaccount/downloads.php +++ b/templates/myaccount/downloads.php @@ -25,9 +25,14 @@ if ( ! defined( 'ABSPATH' ) ) { $downloads = WC()->customer->get_downloadable_products(); $has_downloads = (bool) $downloads; -wc_print_notices(); ?> +wc_print_notices(); - +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
diff --git a/templates/myaccount/form-add-payment-method.php b/templates/myaccount/form-add-payment-method.php index 968d824fd49..809dda5ed98 100644 --- a/templates/myaccount/form-add-payment-method.php +++ b/templates/myaccount/form-add-payment-method.php @@ -20,7 +20,12 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -wc_get_template( 'myaccount/navigation.php' ); ?> +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
payment_gateways->get_available_payment_gateways() ) : ?> diff --git a/templates/myaccount/form-edit-account.php b/templates/myaccount/form-edit-account.php index c4f1e17bb63..6b4eb155e23 100644 --- a/templates/myaccount/form-edit-account.php +++ b/templates/myaccount/form-edit-account.php @@ -22,7 +22,12 @@ if ( ! defined( 'ABSPATH' ) ) { wc_print_notices(); -wc_get_template( 'myaccount/navigation.php' ); ?> +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
diff --git a/templates/myaccount/form-edit-address.php b/templates/myaccount/form-edit-address.php index aa82c0c3444..f0a124a7937 100644 --- a/templates/myaccount/form-edit-address.php +++ b/templates/myaccount/form-edit-address.php @@ -24,7 +24,12 @@ $page_title = ( $load_address === 'billing' ) ? __( 'Billing Address', 'woocomme wc_print_notices(); -wc_get_template( 'myaccount/navigation.php' ); ?> +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
diff --git a/templates/myaccount/my-account.php b/templates/myaccount/my-account.php index ed478c68fa1..4c87cebdd7c 100644 --- a/templates/myaccount/my-account.php +++ b/templates/myaccount/my-account.php @@ -20,9 +20,14 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -wc_print_notices(); ?> +wc_print_notices(); - +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>

diff --git a/templates/myaccount/orders.php b/templates/myaccount/orders.php index 356cbe28465..5ef4a45ac8d 100644 --- a/templates/myaccount/orders.php +++ b/templates/myaccount/orders.php @@ -23,7 +23,13 @@ if ( ! defined( 'ABSPATH' ) ) { } wc_print_notices(); -wc_get_template( 'myaccount/navigation.php' ); ?> + +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>

diff --git a/templates/myaccount/payment-methods.php b/templates/myaccount/payment-methods.php index 8cecf017fad..38029c55718 100644 --- a/templates/myaccount/payment-methods.php +++ b/templates/myaccount/payment-methods.php @@ -25,9 +25,15 @@ if ( ! defined( 'ABSPATH' ) ) { $saved_methods = wc_get_customer_saved_methods_list( get_current_user_id() ); $has_methods = (bool) $saved_methods; $types = wc_get_account_payment_methods_types(); -wc_print_notices(); ?> - +wc_print_notices(); + +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
diff --git a/templates/myaccount/view-order.php b/templates/myaccount/view-order.php index 79baaa97233..b3d2410257a 100644 --- a/templates/myaccount/view-order.php +++ b/templates/myaccount/view-order.php @@ -22,9 +22,14 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -wc_print_notices(); ?> +wc_print_notices(); - +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>

Date: Mon, 30 May 2016 13:35:12 -0300 Subject: [PATCH 02/11] Suit CSS naming for #10994 cc @jameskoster --- includes/admin/meta-boxes/class-wc-meta-box-order-data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/meta-boxes/class-wc-meta-box-order-data.php b/includes/admin/meta-boxes/class-wc-meta-box-order-data.php index 96f9ce5bd9f..f1c83562bf0 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-order-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-order-data.php @@ -188,7 +188,7 @@ class WC_Meta_Box_Order_Data { } if ( $ip_address = get_post_meta( $post->ID, '_customer_ip_address', true ) ) { - echo __( 'Customer IP', 'woocommerce' ) . ': ' . esc_html( $ip_address ) . ''; + echo __( 'Customer IP', 'woocommerce' ) . ': ' . esc_html( $ip_address ) . ''; } ?>

From 2442ec9f4d8285f76774be5a1000c22880af9957 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 30 May 2016 17:15:46 -0300 Subject: [PATCH 03/11] [REST API] Fixed order refunds required fields --- includes/api/class-wc-rest-order-refunds-controller.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/includes/api/class-wc-rest-order-refunds-controller.php b/includes/api/class-wc-rest-order-refunds-controller.php index a9d51d4c6c8..14eb8a67254 100644 --- a/includes/api/class-wc-rest-order-refunds-controller.php +++ b/includes/api/class-wc-rest-order-refunds-controller.php @@ -66,11 +66,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller { 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), - 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( - 'email' => array( - 'required' => true, - ), - ) ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); From f526fe39388cedec4c5f95ad145da39a968d91f4 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 30 May 2016 17:25:39 -0300 Subject: [PATCH 04/11] [REST API] Fixed item description and type in orders refunds schema --- includes/api/class-wc-rest-order-refunds-controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/api/class-wc-rest-order-refunds-controller.php b/includes/api/class-wc-rest-order-refunds-controller.php index 14eb8a67254..ef9668beda6 100644 --- a/includes/api/class-wc-rest-order-refunds-controller.php +++ b/includes/api/class-wc-rest-order-refunds-controller.php @@ -360,7 +360,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller { 'context' => array( 'view', 'edit' ), ), 'reason' => array( - 'description' => __( 'Reason for refund', 'woocommerce' ), + 'description' => __( 'Reason for refund.', 'woocommerce' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), @@ -404,7 +404,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller { ), 'tax_class' => array( 'description' => __( 'Tax class of product.', 'woocommerce' ), - 'type' => 'integer', + 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), From 638d54425acb9be3522ab13a2b97348248791993 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 30 May 2016 17:42:42 -0300 Subject: [PATCH 05/11] [REST API] The only post type that have slugs are products --- includes/abstracts/abstract-wc-rest-posts-controller.php | 6 ------ includes/api/class-wc-rest-products-controller.php | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/includes/abstracts/abstract-wc-rest-posts-controller.php b/includes/abstracts/abstract-wc-rest-posts-controller.php index 4674733f6cc..fa6db5b8050 100644 --- a/includes/abstracts/abstract-wc-rest-posts-controller.php +++ b/includes/abstracts/abstract-wc-rest-posts-controller.php @@ -666,12 +666,6 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller { ); } - $params['slug'] = array( - 'description' => __( 'Limit result set to posts with a specific slug.', 'woocommerce', 'woocommerce' ), - 'type' => 'string', - 'validate_callback' => 'rest_validate_request_arg', - ); - $params['filter'] = array( 'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce' ), ); diff --git a/includes/api/class-wc-rest-products-controller.php b/includes/api/class-wc-rest-products-controller.php index 267750a9f9f..09817b7e7f6 100644 --- a/includes/api/class-wc-rest-products-controller.php +++ b/includes/api/class-wc-rest-products-controller.php @@ -2509,6 +2509,11 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller { public function get_collection_params() { $params = parent::get_collection_params(); + $params['slug'] = array( + 'description' => __( 'Limit result set to posts with a specific slug.', 'woocommerce', 'woocommerce' ), + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', + ); $params['status'] = array( 'default' => 'any', 'description' => __( 'Limit result set to products assigned a specific status.', 'woocommerce' ), From 48b321bd912e6c8551195378a031812c449f7a33 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 30 May 2016 18:01:08 -0300 Subject: [PATCH 06/11] [REST API] Fixed write only parameters in orders and webhooks schemas --- includes/api/class-wc-rest-orders-controller.php | 3 +-- includes/api/class-wc-rest-webhooks-controller.php | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/includes/api/class-wc-rest-orders-controller.php b/includes/api/class-wc-rest-orders-controller.php index 240677a9d95..260745015f7 100644 --- a/includes/api/class-wc-rest-orders-controller.php +++ b/includes/api/class-wc-rest-orders-controller.php @@ -1316,8 +1316,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { 'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce' ), 'type' => 'boolean', 'default' => false, - 'context' => array( 'view', 'edit' ), - 'writeonly' => true, + 'context' => array( 'edit' ), ), 'transaction_id' => array( 'description' => __( 'Unique transaction ID.', 'woocommerce' ), diff --git a/includes/api/class-wc-rest-webhooks-controller.php b/includes/api/class-wc-rest-webhooks-controller.php index 7653d41b36e..a17f0657b12 100644 --- a/includes/api/class-wc-rest-webhooks-controller.php +++ b/includes/api/class-wc-rest-webhooks-controller.php @@ -520,7 +520,6 @@ class WC_REST_Webhooks_Controller extends WC_REST_Posts_Controller { 'type' => 'string', 'format' => 'uri', 'context' => array( 'edit' ), - 'writeonly' => true, ), 'date_created' => array( 'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce' ), From ef90e79356d06f22a14107d57b1f1568b5fc2fd2 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 30 May 2016 18:38:09 -0300 Subject: [PATCH 07/11] [REST API] General fixes in the orders schema --- .../class-wc-rest-order-refunds-controller.php | 2 +- includes/api/class-wc-rest-orders-controller.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/api/class-wc-rest-order-refunds-controller.php b/includes/api/class-wc-rest-order-refunds-controller.php index ef9668beda6..8ba303fbd15 100644 --- a/includes/api/class-wc-rest-order-refunds-controller.php +++ b/includes/api/class-wc-rest-order-refunds-controller.php @@ -435,7 +435,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller { 'context' => array( 'view', 'edit' ), ), 'taxes' => array( - 'description' => __( 'Line total tax.', 'woocommerce' ), + 'description' => __( 'Line taxes.', 'woocommerce' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), 'readonly' => true, diff --git a/includes/api/class-wc-rest-orders-controller.php b/includes/api/class-wc-rest-orders-controller.php index 260745015f7..a7cea579e20 100644 --- a/includes/api/class-wc-rest-orders-controller.php +++ b/includes/api/class-wc-rest-orders-controller.php @@ -1320,7 +1320,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { ), 'transaction_id' => array( 'description' => __( 'Unique transaction ID.', 'woocommerce' ), - 'type' => 'boolean', + 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'customer_ip_address' => array( @@ -1360,7 +1360,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { ), 'cart_hash' => array( 'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ), - 'type' => 'float', + 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), @@ -1377,7 +1377,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { ), 'name' => array( 'description' => __( 'Product name.', 'woocommerce' ), - 'type' => 'integer', + 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), @@ -1435,7 +1435,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { 'context' => array( 'view', 'edit' ), ), 'taxes' => array( - 'description' => __( 'Line total tax.', 'woocommerce' ), + 'description' => __( 'Line taxes.', 'woocommerce' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), 'readonly' => true, @@ -1556,7 +1556,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { ), 'method_id' => array( 'description' => __( 'Shipping method ID.', 'woocommerce' ), - 'type' => 'integer', + 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'total' => array( @@ -1571,7 +1571,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { 'readonly' => true, ), 'taxes' => array( - 'description' => __( 'Line total tax.', 'woocommerce' ), + 'description' => __( 'Line taxes.', 'woocommerce' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), 'readonly' => true, @@ -1619,7 +1619,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { 'context' => array( 'view', 'edit' ), ), 'total' => array( - 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), + 'description' => __( 'Line total (after discounts).', 'woocommerce' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), @@ -1629,7 +1629,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { 'context' => array( 'view', 'edit' ), ), 'taxes' => array( - 'description' => __( 'Line total tax.', 'woocommerce' ), + 'description' => __( 'Line taxes.', 'woocommerce' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), 'readonly' => true, From 83f87fe01a49505439d599ff05e4ef356f673bce Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 30 May 2016 19:22:06 -0300 Subject: [PATCH 08/11] [REST API] Fixed order - variable line items --- includes/api/class-wc-rest-orders-controller.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/api/class-wc-rest-orders-controller.php b/includes/api/class-wc-rest-orders-controller.php index a7cea579e20..25c5d8b1756 100644 --- a/includes/api/class-wc-rest-orders-controller.php +++ b/includes/api/class-wc-rest-orders-controller.php @@ -546,11 +546,11 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { throw new WC_REST_Exception( 'woocommerce_rest_required_product_reference', __( 'Product ID or SKU is required.', 'woocommerce' ), 400 ); } - if ( ! empty( $item['product_id'] ) ) { - $product_id = (int) $item['product_id']; - } else if ( ! empty( $item['sku'] ) ) { + if ( ! empty( $item['sku'] ) ) { $product_id = (int) wc_get_product_id_by_sku( $item['sku'] ); - } else if ( ! empty( $item['variation_id'] ) ) { + } elseif ( ! empty( $item['product_id'] ) && empty( $item['variation_id'] ) ) { + $product_id = (int) $item['product_id']; + } elseif ( ! empty( $item['variation_id'] ) ) { $product_id = (int) $item['variation_id']; } From 94e6d6cb29a263617ebd3b7879b4d9f5d0e3bf64 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 30 May 2016 19:22:26 -0300 Subject: [PATCH 09/11] [REST API] elseif in favor of else if --- includes/api/class-wc-rest-product-attributes-controller.php | 4 ++-- includes/api/class-wc-rest-products-controller.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/api/class-wc-rest-product-attributes-controller.php b/includes/api/class-wc-rest-product-attributes-controller.php index 3e5c1a0820c..3219ffa54a6 100644 --- a/includes/api/class-wc-rest-product-attributes-controller.php +++ b/includes/api/class-wc-rest-product-attributes-controller.php @@ -634,9 +634,9 @@ class WC_REST_Product_Attributes_Controller extends WC_REST_Controller { protected function validate_attribute_slug( $slug, $new_data = true ) { if ( strlen( $slug ) >= 28 ) { return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_too_long', sprintf( __( 'Slug "%s" is too long (28 characters max).', 'woocommerce' ), $slug ), array( 'status' => 400 ) ); - } else if ( wc_check_if_attribute_name_is_reserved( $slug ) ) { + } elseif ( wc_check_if_attribute_name_is_reserved( $slug ) ) { return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term.', 'woocommerce' ), $slug ), array( 'status' => 400 ) ); - } else if ( $new_data && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) { + } elseif ( $new_data && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) { return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use.', 'woocommerce' ), $slug ), array( 'status' => 400 ) ); } diff --git a/includes/api/class-wc-rest-products-controller.php b/includes/api/class-wc-rest-products-controller.php index 09817b7e7f6..99500033bac 100644 --- a/includes/api/class-wc-rest-products-controller.php +++ b/includes/api/class-wc-rest-products-controller.php @@ -1147,7 +1147,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller { // Stock quantity. if ( isset( $request['stock_quantity'] ) ) { wc_update_product_stock( $product->id, wc_stock_amount( $request['stock_quantity'] ) ); - } else if ( isset( $request['inventory_delta'] ) ) { + } elseif ( isset( $request['inventory_delta'] ) ) { $stock_quantity = wc_stock_amount( get_post_meta( $product->id, '_stock', true ) ); $stock_quantity += wc_stock_amount( $request['inventory_delta'] ); @@ -1408,7 +1408,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller { if ( isset( $variation['stock_quantity'] ) ) { wc_update_product_stock( $variation_id, wc_stock_amount( $variation['stock_quantity'] ) ); - } else if ( isset( $request['inventory_delta'] ) ) { + } elseif ( isset( $request['inventory_delta'] ) ) { $stock_quantity = wc_stock_amount( get_post_meta( $variation_id, '_stock', true ) ); $stock_quantity += wc_stock_amount( $request['inventory_delta'] ); From b582febda03d475bcef8c110d3db4d096c388e73 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 30 May 2016 19:45:14 -0300 Subject: [PATCH 10/11] [REST API] Fixed orders date_completed --- includes/api/class-wc-rest-orders-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/api/class-wc-rest-orders-controller.php b/includes/api/class-wc-rest-orders-controller.php index 25c5d8b1756..b3252423300 100644 --- a/includes/api/class-wc-rest-orders-controller.php +++ b/includes/api/class-wc-rest-orders-controller.php @@ -151,7 +151,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { 'customer_user_agent' => $order->customer_user_agent, 'created_via' => $order->created_via, 'customer_note' => $order->customer_note, - 'date_completed' => wc_rest_prepare_date_response( $order->completed_date, true ), + 'date_completed' => wc_rest_prepare_date_response( $order->completed_date ), 'date_paid' => $order->paid_date, 'cart_hash' => $order->cart_hash, 'line_items' => array(), From 3fd54f02817a1a1aedf27a904e91ab85ec41fe91 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 30 May 2016 20:15:50 -0300 Subject: [PATCH 11/11] [REST API] Include default params in batch create --- includes/abstracts/abstract-wc-rest-controller.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/includes/abstracts/abstract-wc-rest-controller.php b/includes/abstracts/abstract-wc-rest-controller.php index eac54f4a357..4beefaed2ef 100644 --- a/includes/abstracts/abstract-wc-rest-controller.php +++ b/includes/abstracts/abstract-wc-rest-controller.php @@ -90,6 +90,18 @@ abstract class WC_REST_Controller extends WP_REST_Controller { if ( ! empty( $items['create'] ) ) { foreach ( $items['create'] as $item ) { $_item = new WP_REST_Request( 'POST' ); + + // Default parameters. + $defaults = array(); + $schema = $this->get_public_item_schema(); + foreach ( $schema['properties'] as $arg => $options ) { + if ( isset( $options['default'] ) ) { + $defaults[ $arg ] = $options['default']; + } + } + $_item->set_default_params( $defaults ); + + // Set request parameters. $_item->set_body_params( $item ); $_response = $this->create_item( $_item );