Conditionally allow stock_quantity to be non-integer in REST API product schema (#48541)

This commit is contained in:
Jorge A. Torres 2024-06-18 16:10:54 +01:00 committed by GitHub
parent da329a1620
commit fb25aa86a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Allow products with non-integer stock to be created via REST API.

View File

@ -1951,7 +1951,7 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller {
),
'stock_quantity' => array(
'description' => __( 'Stock quantity.', 'woocommerce' ),
'type' => 'integer',
'type' => has_filter( 'woocommerce_stock_amount', 'intval' ) ? 'integer' : 'number',
'context' => array( 'view', 'edit' ),
),
'in_stock' => array(

View File

@ -1908,7 +1908,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller {
),
'stock_quantity' => array(
'description' => __( 'Stock quantity.', 'woocommerce' ),
'type' => 'integer',
'type' => has_filter( 'woocommerce_stock_amount', 'intval' ) ? 'integer' : 'number',
'context' => array( 'view', 'edit' ),
),
'in_stock' => array(

View File

@ -1131,7 +1131,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
),
'stock_quantity' => array(
'description' => __( 'Stock quantity.', 'woocommerce' ),
'type' => 'integer',
'type' => has_filter( 'woocommerce_stock_amount', 'intval' ) ? 'integer' : 'number',
'context' => array( 'view', 'edit' ),
),
'stock_status' => array(