woocommerce/includes/api/wc-rest-orders-controller.php

58 lines
1.1 KiB
PHP

<?php
/**
* REST API Orders controller
*
* Handles requests to the /orders endpoint.
*
* @author WooThemes
* @category API
* @package WooCommerce/API
* @since 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* REST API Orders controller class.
*
* @package WooCommerce/API
* @extends WC_REST_Posts_Controller
*/
class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
/**
* Route base.
*
* @var string
*/
protected $rest_base = 'orders';
/**
* Post type.
*
* @var string
*/
protected $post_type = 'shop_order';
/**
* Register the routes for orders.
*/
public function register_routes() {
register_rest_route( WC_API::REST_API_NAMESPACE, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
array(
'methods' => WP_REST_Server::DELETABLE,
'callback' => array( $this, 'delete_item' ),
'permission_callback' => array( $this, 'delete_item_permissions_check' ),
'args' => array(
'force' => array(
'default' => false,
'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
),
),
),
) );
}
}