[Rest] Refunds add api_restock param to restock items
This commit is contained in:
parent
b88b868ab8
commit
3e17c0b618
|
@ -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, 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,
|
||||
|
@ -35,13 +36,14 @@ class RestApiUtil {
|
|||
* ...to the internally used format:
|
||||
*
|
||||
* [
|
||||
* "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")
|
||||
* "line_items" => [ (convert sequential array to associative based on "id")
|
||||
* "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")
|
||||
* "qty" => 222, (rename "quantity" to "qty")
|
||||
* "refund_total" => 333,
|
||||
* "refund_tax" => [ (convert sequential array to associative based on "id" and "refund_total)
|
||||
* "refund_tax" => [ (convert sequential array to associative based on "id" and "refund_total)
|
||||
* "444" => 555,...
|
||||
* ],...
|
||||
* ]
|
||||
|
@ -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