API - Rather than error, add users to blog like the checkout does
This commit is contained in:
parent
668c078bcf
commit
4f4d7e6c9c
|
@ -162,7 +162,7 @@ class WC_REST_Orders_Controller extends WC_REST_Orders_V2_Controller {
|
|||
|
||||
// Make sure customer is part of blog.
|
||||
if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id_network', __( 'Customer ID does not belong to this site.', 'woocommerce' ), 400 );
|
||||
add_user_to_blog( get_current_blog_id(), $request['customer_id'], 'customer' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ class WC_REST_Legacy_Orders_Controller extends WC_REST_CRUD_Controller {
|
|||
|
||||
// Make sure customer is part of blog.
|
||||
if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id_network',__( 'Customer ID does not belong to this site.', 'woocommerce' ), 400 );
|
||||
add_user_to_blog( get_current_blog_id(), $request['customer_id'], 'customer' );
|
||||
}
|
||||
|
||||
$order = $this->prepare_item_for_database( $request );
|
||||
|
|
|
@ -536,7 +536,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
// Make sure customer is part of blog.
|
||||
if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id_network',__( 'Customer ID does not belong to this site.', 'woocommerce' ), 400 );
|
||||
add_user_to_blog( get_current_blog_id(), $request['customer_id'], 'customer' );
|
||||
}
|
||||
|
||||
$order = $this->prepare_item_for_database( $request );
|
||||
|
|
|
@ -529,7 +529,7 @@ class WC_REST_Orders_V2_Controller extends WC_REST_Legacy_Orders_Controller {
|
|||
|
||||
// Make sure customer is part of blog.
|
||||
if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) {
|
||||
throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id_network', __( 'Customer ID does not belong to this site.', 'woocommerce' ), 400 );
|
||||
add_user_to_blog( get_current_blog_id(), $request['customer_id'], 'customer' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue