Use a new overrideable function to create orders and custom order types

This commit is contained in:
matttallan 2016-05-24 12:21:48 +10:00
parent 1199410e3d
commit 9fb0882c3c
1 changed files with 12 additions and 1 deletions

View File

@ -434,7 +434,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce' ), 400 ); throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce' ), 400 );
} }
$order = wc_create_order( array( $order = $this->create_base_order( array(
'status' => $request['status'], 'status' => $request['status'],
'customer_id' => $request['customer_id'], 'customer_id' => $request['customer_id'],
'customer_note' => $request['customer_note'], 'customer_note' => $request['customer_note'],
@ -1718,4 +1718,15 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
return $params; return $params;
} }
/**
* Create base WC Order object.
*
* @since 2.6
* @param array $args
* @return WC_Order
*/
protected function create_base_order( $args ) {
return wc_create_order( $args );
}
} }