Update WC API v1 and v2 to use post_author instead of _customer_user
This commit is contained in:
parent
b97f2749d6
commit
fdfe95b07e
|
@ -359,15 +359,20 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $request['customer'] ) ) {
|
if ( isset( $request['customer'] ) ) {
|
||||||
if ( ! empty( $args['meta_query'] ) ) {
|
// On WC 3.5.0 the ID of the user that placed the order was moved from the post meta _customer_user to the post_author field in the wp_posts table.
|
||||||
$args['meta_query'] = array(); // WPCS: slow query ok.
|
if ( version_compare( get_option( 'woocommerce_db_version' ), '3.5.0', '>=' ) ) {
|
||||||
}
|
$args['author'] = $request['customer'];
|
||||||
|
} else {
|
||||||
|
if ( ! empty( $args['meta_query'] ) ) {
|
||||||
|
$args['meta_query'] = array(); // WPCS: slow query ok.
|
||||||
|
}
|
||||||
|
|
||||||
$args['meta_query'][] = array(
|
$args['meta_query'][] = array(
|
||||||
'key' => '_customer_user',
|
'key' => '_customer_user',
|
||||||
'value' => $request['customer'],
|
'value' => $request['customer'],
|
||||||
'type' => 'NUMERIC',
|
'type' => 'NUMERIC',
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search by product.
|
// Search by product.
|
||||||
|
|
|
@ -404,15 +404,20 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $request['customer'] ) ) {
|
if ( isset( $request['customer'] ) ) {
|
||||||
if ( ! empty( $args['meta_query'] ) ) {
|
// On WC 3.5.0 the ID of the user that placed the order was moved from the post meta _customer_user to the post_author field in the wp_posts table.
|
||||||
$args['meta_query'] = array();
|
if ( version_compare( get_option( 'woocommerce_db_version' ), '3.5.0', '>=' ) ) {
|
||||||
}
|
$args['author'] = $request['customer'];
|
||||||
|
} else {
|
||||||
|
if ( ! empty( $args['meta_query'] ) ) {
|
||||||
|
$args['meta_query'] = array(); // WPCS: slow query ok.
|
||||||
|
}
|
||||||
|
|
||||||
$args['meta_query'][] = array(
|
$args['meta_query'][] = array(
|
||||||
'key' => '_customer_user',
|
'key' => '_customer_user',
|
||||||
'value' => $request['customer'],
|
'value' => $request['customer'],
|
||||||
'type' => 'NUMERIC',
|
'type' => 'NUMERIC',
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search by product.
|
// Search by product.
|
||||||
|
|
Loading…
Reference in New Issue