-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Add CustomersController: Vendor-specific CRUD, Batch, and Search API for Customer Management #2406
Feat: Add CustomersController: Vendor-specific CRUD, Batch, and Search API for Customer Management #2406
Conversation
This commit introduces a new REST API endpoint for searching customers specific to a vendor's orders. Key changes include: - Add new route `/dokan/v1/customers/search` in CustomersController - Implement `search_customers` method with the following features: * Search customers by ID or term (name/email) * Limit results to customers who have ordered from the current vendor * Support excluding specific customer IDs * Limit results to 20 when search term is less than 3 characters * Apply `dokan_json_search_found_customers` filter for extensibility - Add permission check to ensure only users with 'edit_shop_orders' capability can access - Include detailed PHPDoc for the new filter This feature allows vendors to efficiently search their customer base through the REST API, mirroring the functionality of the existing AJAX action while providing a standardized API interface.
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce a new Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (1)
includes/REST/Manager.php (1)
237-237
: LGTM! Consider adding a comment for clarity.The addition of the
CustomersController
to the class map is correct and aligns with the PR objectives. This will enable the new REST API endpoint for vendor-specific customer search.For consistency with other recent additions, consider adding a comment above this line to briefly describe the purpose of this controller:
+ // Controller for handling customer-related REST API endpoints DOKAN_DIR . '/includes/REST/CustomersController.php' => '\WeDevs\Dokan\REST\CustomersController',
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- includes/REST/CustomersController.php (1 hunks)
- includes/REST/Manager.php (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Run PHPCS inspection
includes/REST/CustomersController.php
[failure] 28-28:
Opening parenthesis of a multi-line function call must be the last content on the line
[failure] 45-45:
Closing parenthesis of a multi-line function call must be on a line by itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls add Test case for Customer
@mrabbani I've implemented comprehensive test cases for the CustomerController API as requested. |
…ses for Customer API
1e08979
to
c56dacb
Compare
8b2b753
into
getdokan:update/vendor-dashboard-structure
All Submissions:
Changes proposed in this Pull Request:
This PR introduces a new
CustomersController
class that implements REST API endpoints for vendor-specific customer management. This new controller allows vendors to perform various operations on their customer base through the REST API, providing a comprehensive set of endpoints for customer-related actions.Key changes include:
CustomersController
class extendingWC_REST_Customers_Controller
/dokan/v1/customers
- List customers/dokan/v1/customers
- Create a new customer/dokan/v1/customers/{id}
- Retrieve a specific customer/dokan/v1/customers/{id}
- Update a specific customer/dokan/v1/customers/{id}
- Delete a specific customer/dokan/v1/customers/batch
- Batch update customers/dokan/v1/customers/search
- Search for customers (new vendor-specific functionality)dokan_json_search_found_customers
Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
/wp-json/dokan/v1/customers
- Should list customers for the vendor/wp-json/dokan/v1/customers
- Should create a new customer/wp-json/dokan/v1/customers/{id}
- Should retrieve a specific customer/wp-json/dokan/v1/customers/{id}
- Should update a specific customer/wp-json/dokan/v1/customers/{id}
- Should delete a specific customer/wp-json/dokan/v1/customers/batch
- Should perform batch operations on customers/wp-json/dokan/v1/customers/search?search=John
- Should search for customersChangelog entry
Feat: Add CustomersController: Vendor-specific CRUD, Batch, and Search API for Customer Management
This PR introduces a new
CustomersController
class that implements a set of REST API endpoints allowing vendors to manage and search for their customers. This new controller provides CRUD operations for customers, as well as a vendor-specific search functionality, offering a standardized and accessible interface for developers and external applications to interact with vendor-specific customer data.Before Changes
Previously, vendor-specific customer management and search functionality were limited and not easily accessible through a standardized API. Vendors had to rely on AJAX actions or custom implementations to manage their customer data.
After Changes
With this change, a new
CustomersController
class is introduced, providing a comprehensive set of REST API endpoints for vendor-specific customer management. These endpoints allow vendors to list, create, retrieve, update, and delete customers, as well as perform batch operations and conduct searches. The new controller ensures proper permission checks and adheres to WordPress and WooCommerce coding standards.Feature Video (optional)
N/A
PR Self Review Checklist:
FOR PR REVIEWER ONLY:
Summary by CodeRabbit
New Features
Improvements