Use a new overrideable function to create orders and custom order types
This commit is contained in:
parent
1199410e3d
commit
9fb0882c3c
|
@ -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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue