Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand All @@ -432,13 +432,13 @@ public function get_item_schema() {
),
'name' => array(
'description' => __( 'Product name.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'product_id' => array(
'description' => __( 'Product ID.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'integer', 'null' ),
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
Expand Down Expand Up @@ -535,7 +535,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
Expand Down
24 changes: 12 additions & 12 deletions src/Controllers/Version2/class-wc-rest-orders-v2-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand All @@ -1191,12 +1191,12 @@ public function get_item_schema() {
),
'name' => array(
'description' => __( 'Product name.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
'product_id' => array(
'description' => __( 'Product ID.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'integer' ),
'context' => array( 'view', 'edit' ),
),
'variation_id' => array(
Expand Down Expand Up @@ -1282,7 +1282,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand Down Expand Up @@ -1373,7 +1373,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand All @@ -1397,12 +1397,12 @@ public function get_item_schema() {
),
'method_title' => array(
'description' => __( 'Shipping method name.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
'method_id' => array(
'description' => __( 'Shipping method ID.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
'instance_id' => array(
Expand Down Expand Up @@ -1464,7 +1464,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand All @@ -1488,7 +1488,7 @@ public function get_item_schema() {
),
'name' => array(
'description' => __( 'Fee name.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
'tax_class' => array(
Expand Down Expand Up @@ -1562,7 +1562,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand All @@ -1586,7 +1586,7 @@ public function get_item_schema() {
),
'code' => array(
'description' => __( 'Coupon code.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
'discount' => array(
Expand Down Expand Up @@ -1620,7 +1620,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ public function get_item_schema() {
),
'manage_stock' => array(
'description' => __( 'Stock management at variation level.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'boolean', 'null' ),
'default' => false,
'context' => array( 'view', 'edit' ),
),
Expand Down Expand Up @@ -982,7 +982,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,18 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Setting value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'array', 'null' ),
'items' => array(
'type' => array( 'string', 'null' ),
),
'context' => array( 'view', 'edit' ),
),
'default' => array(
'description' => __( 'Default value for the setting.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'array', 'null' ),
'items' => array(
'type' => array( 'string', 'null' ),
),
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
Expand Down
29 changes: 29 additions & 0 deletions src/Controllers/Version3/class-wc-rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,35 @@ protected function add_additional_fields_schema( $schema ) {
return $schema;
}

/**
* Compatibility functions for WP 5.5, since custom types are not supported anymore.
* See @link https://core.trac.wordpress.org/changeset/48306
*
* @param string $method Optional. HTTP method of the request.
*
* @return array Endpoint arguments.
*/
public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {

$endpoint_args = parent::get_endpoint_args_for_item_schema( $method );

if ( false === strpos( WP_REST_Server::EDITABLE, $method ) ) {
return $endpoint_args;
}

foreach ( $endpoint_args as $field_id => $params ) {
/**
* Custom types are not supported as of WP 5.5, this translates type => 'date-time' to type => 'string' with format date-time.
*/
if ( 'date-time' === $params['type'] ) {
$endpoint_args[ $field_id ]['type'] = 'string';
$endpoint_args[ $field_id ]['format'] = 'date-time';
}
}

return $endpoint_args;
}

/**
* Get normalized rest base.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Controllers/Version3/class-wc-rest-crud-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public function delete_item_permissions_check( $request ) {
return true;
}



/**
* Get object permalink.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'null' ),
'context' => array( 'view', 'edit' ),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,18 @@ public function get_item_schema() {
),
'value' => array(
'description' => __( 'Setting value.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'array', 'null' ),
'items' => array(
'type' => array( 'string', 'null' ),
),
'context' => array( 'view', 'edit' ),
),
'default' => array(
'description' => __( 'Default value for the setting.', 'woocommerce-rest-api' ),
'type' => 'mixed',
'type' => array( 'string', 'array', 'null' ),
'items' => array(
'type' => array( 'string', 'null' ),
),
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
Expand Down