WC_REST_Order_Refunds_Controller::register_routes
Register the routes for order refunds, including the refund preview route.
The override is new in 11.1.0 even though the parent method is not, hence the tag per the convention for public methods.
Method of the class: WC_REST_Order_Refunds_Controller{}
No Hooks.
Returns
void. Nothing (null).
Usage
$WC_REST_Order_Refunds_Controller = new WC_REST_Order_Refunds_Controller(); $WC_REST_Order_Refunds_Controller->register_routes();
Changelog
| Since 11.1.0 | Introduced. |
WC_REST_Order_Refunds_Controller::register_routes() WC REST Order Refunds Controller::register routes code WC 11.3.0
public function register_routes() {
parent::register_routes();
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/preview',
array(
'args' => array(
'order_id' => array(
'description' => __( 'The order ID.', 'woocommerce' ),
'type' => 'integer',
),
),
// permission_callback below intentionally uses the create-refund capability:
// preview is read-only but logically part of the refund-creation flow, so it
// requires the same capability. This prevents read-only-API clients from
// probing refund state on orders they cannot act on.
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'preview_refund' ),
'permission_callback' => array( $this, 'create_item_permissions_check' ),
'args' => array(
'line_items' => $this->get_preview_line_items_arg_schema(),
),
),
'schema' => array( $this, 'get_public_preview_schema' ),
)
);
}