Merge pull request #30179 from fitimvata/trunk
[Rest] Refunds add api_restock param to restock items
This commit is contained in:
commit
1c1f6fdc0f
|
@ -56,7 +56,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Order_Refunds_V2_Controll
|
|||
'reason' => $request['reason'],
|
||||
'line_items' => $request['line_items'],
|
||||
'refund_payment' => $request['api_refund'],
|
||||
'restock_items' => true,
|
||||
'restock_items' => $request['api_restock'],
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -110,6 +110,13 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Order_Refunds_V2_Controll
|
|||
'readonly' => true,
|
||||
);
|
||||
|
||||
$schema['properties']['api_restock'] = array(
|
||||
'description' => __( 'When true, refunded items are restocked.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'edit' ),
|
||||
'default' => true,
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ class RestApiUtil {
|
|||
* [
|
||||
* "reason" => "",
|
||||
* "api_refund" => "x",
|
||||
* "api_restock" => "x",
|
||||
* "line_items" => [
|
||||
* "id" => "111",
|
||||
* "quantity" => 222,
|
||||
|
@ -37,6 +38,7 @@ class RestApiUtil {
|
|||
* [
|
||||
* "reason" => null, (if it's missing or any empty value, set as null)
|
||||
* "api_refund" => true, (if it's missing or non-bool, set as "true")
|
||||
* "api_restock" => true, (if it's missing or non-bool, set as "true")
|
||||
* "line_items" => [ (convert sequential array to associative based on "id")
|
||||
* "111" => [
|
||||
* "qty" => 222, (rename "quantity" to "qty")
|
||||
|
@ -66,6 +68,10 @@ class RestApiUtil {
|
|||
$request['api_refund'] = true;
|
||||
}
|
||||
|
||||
if ( ! is_bool( $request['api_restock'] ) ) {
|
||||
$request['api_restock'] = true;
|
||||
}
|
||||
|
||||
if ( empty( $request['line_items'] ) ) {
|
||||
$request['line_items'] = array();
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue