Skip to content

Commit

Permalink
update: support include & exclude support in dokan product
Browse files Browse the repository at this point in the history
  • Loading branch information
osmansufy committed Jan 1, 2025
1 parent 4a5d435 commit b5dd089
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions includes/REST/ProductControllerV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function register_routes() {
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_items' ],
'args' => $this->get_product_collection_params(),
'permission_callback' => [ $this, 'get_product_permissions_check' ],
],
'schema' => [ $this, 'get_item_schema' ],
Expand Down Expand Up @@ -119,7 +118,7 @@ private function set_chosen_categories( $response ) {
*
* @return array Query parameters.
*/
public function get_product_collection_params() {
public function get_collection_params() {
$params = parent::get_collection_params();

$params['author'] = array(
Expand Down Expand Up @@ -177,6 +176,24 @@ public function get_product_collection_params() {
'validate_callback' => 'rest_validate_request_arg',
'required' => false,
);
$params['include'] = array(
'description' => __( 'Limit result set to specific ids.', 'dokan-lite' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'default' => array(),
'sanitize_callback' => 'wp_parse_id_list',
);
$params['exclude'] = array(
'description' => __( 'Ensure result set excludes specific IDs.', 'dokan-lite' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'default' => array(),
'sanitize_callback' => 'wp_parse_id_list',
);

return $params;
}
Expand Down

0 comments on commit b5dd089

Please sign in to comment.