Made path /orders/refund_id return invalid order id msg.

This commit is contained in:
Peter Fabian 2018-06-07 13:26:29 +02:00
parent db9ab9cb8f
commit db9d2f2c30
1 changed files with 9 additions and 3 deletions

View File

@ -127,14 +127,20 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
} }
/** /**
* Get object. * Get object. Return false if object is not of required type.
* *
* @since 3.0.0 * @since 3.0.0
* @param int $id Object ID. * @param int $id Object ID.
* @return WC_Data * @return WC_Data|bool
*/ */
protected function get_object( $id ) { protected function get_object( $id ) {
return wc_get_order( $id ); $order = wc_get_order( $id );
// In case id is a refund's id (or it's not an order at all), don't expose it via /orders/ path.
if ( ! $order || 'shop_order_refund' === $order->get_type() ) {
return false;
}
return $order;
} }
/** /**