Skip to content

Commit

Permalink
Add global_unique_id parameter to products REST API (woocommerce#51264)
Browse files Browse the repository at this point in the history
* Add global_unique_id parameter to products REST API

* Remove unnecessary if statement related to commas and trim request content
  • Loading branch information
nathanss authored Sep 18, 2024
1 parent 9d135ee commit 9671913
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add global_unique_id parameter to products REST API
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ protected function prepare_objects_query( $request ) {
}
}

if ( ! empty( $request['global_unique_id'] ) ) {
$global_unique_ids = array_map( 'trim', explode( ',', $request['global_unique_id'] ) );
$args['meta_query'] = $this->add_meta_query( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
$args,
array(
'key' => '_global_unique_id',
'value' => $global_unique_ids,
'compare' => 'IN',
)
);
}

// Filter by tax class.
if ( ! empty( $request['tax_class'] ) ) {
$args['meta_query'] = $this->add_meta_query( // WPCS: slow query ok.
Expand Down

0 comments on commit 9671913

Please sign in to comment.