API - Rather than error, add users to blog like the checkout does

This commit is contained in:
Mike Jolley 2019-01-14 16:31:52 +00:00
parent 668c078bcf
commit 4f4d7e6c9c
4 changed files with 4 additions and 4 deletions

View File

@ -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' );
}
}

View File

@ -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 );

View File

@ -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 );

View File

@ -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' );
}
}