Closed mralaminahamed closed 1 month ago
[!IMPORTANT]
Review skipped
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yaml
file in this repository. To trigger a single review, invoke the@coderabbitai review
command.You can disable this status message by setting the
reviews.review_status
tofalse
in the CodeRabbit configuration file.
The changes introduce a new CustomersController
class within the Dokan plugin framework, enhancing the REST API for managing customer data. This controller extends the existing WC_REST_Customers_Controller
and adds functionalities such as a new search endpoint. The Manager
class is updated to register this new controller in the REST API class map, enabling it to handle requests related to customer management, including permission checks and data preparation.
File | Change Summary |
---|---|
includes/REST/CustomersController.php | - Added CustomersController class. - Implemented methods for registering routes, searching customers, and permission checks. - Updated methods to enforce vendor permissions and prepare customer data for the database. |
includes/REST/Manager.php | - Added mapping for CustomersController in the $class_map array within the get_rest_api_class_map method. |
In the land of code where rabbits play,
A new controller hops in, brightening the day.
Searching for customers, oh what a delight,
With permissions in check, everything's right!
So let’s celebrate this change, oh so grand,
For in the world of plugins, we take a stand! 🐇✨
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?
@mrabbani I've implemented comprehensive test cases for the CustomerController API as requested.
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