From 8605ada7cf3ffd22dafc3b4a6c79b24b9afcfa79 Mon Sep 17 00:00:00 2001 From: Warren Wang Date: Thu, 25 Feb 2021 18:01:49 +0800 Subject: [PATCH 1/2] Fix for issue #27553 REST API v3 shipping method zone endpoint input payload not allowing settings type to be of type `class` or `order`. Added missing item schema. --- ...-wc-rest-shipping-zone-methods-controller.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/includes/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php b/includes/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php index 32b59d0771f..e610849c56e 100644 --- a/includes/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php +++ b/includes/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php @@ -24,4 +24,20 @@ class WC_REST_Shipping_Zone_Methods_Controller extends WC_REST_Shipping_Zone_Met * @var string */ protected $namespace = 'wc/v3'; + + /** + * Get the settings schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + // Get parent schema to append additional supported settings types for shipping zone method + $schema = parent::get_item_schema(); + + //append additional settings supported types (class, order) + $schema['properties']['settings']['properties']['type']['enum'][] = 'class'; + $schema['properties']['settings']['properties']['type']['enum'][] = 'order'; + + return $this->add_additional_fields_schema( $schema ); + } } From d6b2e91c9d29cc41e5635ce098115a5536238691 Mon Sep 17 00:00:00 2001 From: Warren Wang Date: Fri, 26 Feb 2021 13:45:20 +0800 Subject: [PATCH 2/2] Minor adjustments to fit coding standards Added periods to comments and proper spacing and capitalization to comments. --- .../class-wc-rest-shipping-zone-methods-controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php b/includes/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php index e610849c56e..f03234e0633 100644 --- a/includes/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php +++ b/includes/rest-api/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php @@ -31,10 +31,10 @@ class WC_REST_Shipping_Zone_Methods_Controller extends WC_REST_Shipping_Zone_Met * @return array */ public function get_item_schema() { - // Get parent schema to append additional supported settings types for shipping zone method + // Get parent schema to append additional supported settings types for shipping zone method. $schema = parent::get_item_schema(); - //append additional settings supported types (class, order) + // Append additional settings supported types (class, order). $schema['properties']['settings']['properties']['type']['enum'][] = 'class'; $schema['properties']['settings']['properties']['type']['enum'][] = 'order';